Forum Replies Created

Viewing 15 posts - 1 through 15 (of 19 total)

  • RE: SQL Pivot help

    Hi,

    This query may be helpfull

    select * from

    (

    select * from wip_master

    ) p

    pivot

    (

    sum(qty) for code in ([CLM],[CON],[DAM],[FIN],[MIL],[NON],[REP],[RRT],[SHT])

    ) as result

  • RE: count

    Hi,

    I think you may expected below results.

    DECLARE @sampleData TABLE (

    metric_name varchar(20),

    num tinyint

    )

    INSERT INTO @sampleData

    VALUES

    ('F3M_FCST',1)

    ,('L3M_SALES',2)

    ,('QTR_TRACKING',3)

    ,('SALES_VS_PRIOR',4)

    ,('F3M_FCST',1)

    ,('L3M_SALES',2)

    ,('QTR_TRACKING',3)

    ,('SALES_VS_PRIOR',4)

    ,('F3M_FCST',1)

    ,('L3M_SALES',2)

    ,('QTR_TRACKING',3)

    ,('SALES_VS_PRIOR',4)

    ,('F3M_FCST',1)

    ,('L3M_SALES',2)

    ,('QTR_TRACKING',3)

    ,('SALES_VS_PRIOR',4)

    select * from ( select *,ROW_NUMBER()over(PARTITION by num order by...

  • RE: Alter column from datetimeoffset to datetime when index is dependent on it.

    For statistics also same procedure?. if same procedure is there any script to get create statistics script dynamically based on table and column name.

  • RE: Alter column from datetimeoffset to datetime when index is dependent on it.

    Hi,

    Is there any other solution except drop and recreate index.

    while recreate index i got below error

    Msg 7999, Level 16, State 9, Line 1

    Could not find any index...

  • RE: Combine date and hour fields

    Hi,

    select DATEADD(hh,12,'2015-04-09 00:00:00.000')

    Replace 12 and '2015-04-09 00:00:00.000' with your table column name "Hour" and "Date"

  • RE: How to get salarycode,salaryname in 2 seperate columns (list) ,based on salarycode using sql query

    select T1.salaryname,T2.salaryname from

    (

    select ROW_NUMBER() over(order by salarycode ) as No,cast(salarycode as varchar)+salaryname as salaryname from basic where salarycode=1) T1

    left join

    (select ROW_NUMBER() over(order by salarycode ) as No,cast(salarycode ...

  • RE: Convert row into column and generate dynamic columns

    Hi Lowell,

    here is my table structure,

    create table #temptable

    (

    ResourceName varchar(100),

    ResourceCode varchar(100),

    RecordID varchar(100),

    Program varchar(100),

    Laboratory varchar(100),

    Test_Date varchar(30),

    Analyte varchar(50),

    DetectedValue varchar(100),

    UOM varchar(20),

    CorrectiveAction varchar(100),

    AnalyteComments varchar(500)

    )

  • RE: how to calculate percentage on based on column values

    Hi chrism,

    Thanks a lot.

  • RE: Check constraint fail while updating row

    hi,

    updated priroty_hashvalue column also like below but it's constraint violated

    update testtable set priroty1=@priroty1,

    priroty2=@priroty2,

    priroty3=@priroty3,

    priroty_hashvalue=hashbytes('md5',@priroty1+@priroty2+@priroty3) where clause.

  • RE: Check constraint fail while updating row

    Priority_hashvalue genereate like below

    insert into testtable(priroty1,priroty2,priroty3,Priority_hashvalue) values(@priroty1,@priroty2,@priroty3,hashbytes('md5',(@priroty1+@priroty2+priroty3)))

  • RE: sql server 2008 r2 sp1 intellisense not working

    Hi Valued Member,

    i have install vs sp1 in my system,for rectify this problem which software(hot fix) i have to install .

    Below are sql server version details which i use in...

  • RE: The transaction log for database is full.

    Full.

  • RE: Using fetch and cursor in a while loop

    Hi try this.

    ******START******

    -- Declare the variables to store the values returned by FETCH.

    DECLARE @truck varchar(3), @min_lic varchar(12);

    DECLARE id_cursor CURSOR FOR

    SELECT truck,min_lic FROM KPIPlukkTidStart;

    OPEN id_cursor;

    Fetch Next From id_cursor into @truck,@min_lic

    -- Check...

  • RE: Best way to do same.

    Hi surindersinghthakur,

    insert into doc values(1,'A')

    insert into doc values(3,'A')

    the above records was not match with Code='I' in doc table right .but you are not displaying in query output result.those records you...

  • RE: to find specific position string

    hi,

    before finding sub string you should trim the data otherwise it takes empty data also.

    select id,SUBSTRING(Reverse(LTRIM(RTRIM(name))),3,1) from emp

Viewing 15 posts - 1 through 15 (of 19 total)