Forum Replies Created

Viewing 15 posts - 16 through 30 (of 47 total)

  • RE: Sum fields from multiple tables

    begin

    declare @param varchar(10),@dateFrom varchar(10)='09/13/2011'

    declare @output nvarchar(255),@output1 nvarchar(255)

    declare @tab_cnt int,@init int= 1,@query nvarchar(500)

    declare @input_filename table (sno int identity (1,1),table_name varchar(20))

    declare @output_tab table (sno int identity(1,1),table_name varchar(20),cnt int)

    set @output = N'@outputval nvarchar(255)...

  • RE: managers having more than 3 emp working under him

    Hi

    I am using basic emp table.

    select * from EMP a where exists(

    select mgr from EMP b where a.MGR= b.mgr group by mgr having count(*)>2)

    order by mgr

    Regards

    Siva Kumar...

  • RE: Complicated Query Need Some Help :(

    Hi

    You can try this.

    declare @tab table (prodid int,amt int,qty int,salesdate date)

    insert into @tab values (1,1000,10,'2011-11-01'),

    (2,1500,15,'2011-12-01'),

    ...

  • RE: SQL SERVER(T-SQL)

    Hi

    This is the other way.

    Select 'Select'

    union all

    Select 'from'

    union all

    select 'where'

    union all

    select 'group by'

    Regards

    Siva Kumar J.

  • RE: Which procedures or function srae using my table???

    Hi,

    select 'sp_depends '+''''+table_schema+'.'+table_name+'''' from information_schema.tables

    regards

    Siva Kumar J.

  • RE: cursor in SQL

    Hi

    Following is another way to get rid of duplicate data

    DECLARE @tmpTable table(

    [id] [varchar] (30),

    [firstname] [varchar] (30),

    [lastname] [varchar] (30),

    [company] [varchar] (100)

    )

    INSERT @tmpTable SELECT '902','suresh','bangalore','sm soft'

    INSERT @tmpTable SELECT '905','ramesh','xyz','company llc'

    INSERT @tmpTable SELECT...

  • RE: FURTHER GROUPING OF RECORDS

    Hi

    -- for dataset 1

    select * from #Cartesis_to_hfm a where exists(

    select CartesisRU,CartesisBU,COUNT(*) from #Cartesis_to_hfm b

    where a.CartesisBU = b.CartesisBU and a.CartesisRU = b.CartesisRU

    group by CartesisRU,CartesisBU having COUNT(*)>1)

    -- for dataset 2

    select *...

  • RE: help about dinamic query

    Hi

    Following my help for you.

    ----- code ------

    declare

    @baslik varchar(max),@resim varchar(max),@tablo varchar(50),

    @sira varchar(10),

    @id varchar(10)

    set @tablo = 'emp'

    declare @sqlcum nvarchar(max)

    set @sqlcum ='update '+@tablo

    +' set baslik = '+isnull(@baslik,'''''')+','

    +' resim = '+isnull(@resim,'''''')+','

    +' sirano = '+isnull(@sira,'''''')+

    '...

  • RE: Reg stored procs deployment

    Hi

    Go to SSMS

    select the required db from databases

    rightclick->Tasks->Generate Scripts

    set true/false for required options

    then select required tables/functions/procedures

    save the results to a script to file/script to query window/script to clipboard.

    Then copy the...

  • RE: Reg stored procs deployment

    Hi

    Generate the script file using Generate scripts option. Then execute that sql file in required areas.

    Regards

    Siva Kumar J

  • RE: If Exists Update else Insert into table

    Hi

    You can use MERGE statement, in sql 2008R2. This may be helpful.

    http://technet.microsoft.com/en-us/library/bb510625.aspx

    Regards

    Siva Kumar J.

  • RE: my first cursor - almost working

    check this....

    -----------------

    DECLARE @TableName varchar(max)

    DECLARE getTableName CURSOR FOR

    select ss.name + '.' + o.name as table_name

    from sys.objects o

    join sys.schemas ss on ss.schema_id = o.schema_id

    where type = 'u' and

    ss.name + '.' +...

  • RE: Problem with fetch and cursor

    Hi,

    Modified the given query. Now its running perfectly.

    declare

    @organization varchar(16),

    @data_view varchar(16),

    @subgroup varchar(16),

    @i int

    set @i=0

    DECLARE org_cursor CURSOR FOR

    select organization, data_view, subgroup from test

    open org_cursor

    fetch next from org_cursor

    into @organization, @data_view,...

  • RE: How to read text file into SQL Table

    I given you the solution how to extract data from text file to Sql server Table. This code is purely Sql Server.:w00t:

    Siva

  • RE: How to read text file into SQL Table

    Hi

    It is very easy to load data from text,csv etc to oracle tables using External Table concept.

    You load external data (.txt,.csv etc) into sql table in following way.

    step1:

    IF EXISTS...

Viewing 15 posts - 16 through 30 (of 47 total)