Forum Replies Created

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

  • RE: Selecting the Row with the MAX(DateStarted)

    dwain.c (10/16/2013)


    As long as you don't have any duplicates in the MAX date:

    SELECT * FROM #AllData WHERE CONVERT(VARCHAR(20),DateStarted) + CONVERT(VARCHAR(30), ProductID) IN(

    SELECT CONVERT(VARCHAR(20),max(DateStarted))+ CONVERT(VARCHAR(30), ProductID) FROM #AllData

    group BY ProductID)

  • RE: Need help in SQL Query

    Please provide the Sample data and the result how you expect?

  • RE: How to Join the two table

    What are you expecting?

  • RE: lookup table for minutes of a day

    Hi,

    You can try with help of replace and convert functions

    REPLACE(CONVERT(CHAR(16),DATEADD( MINUTE, DATEDIFF( MINUTE, 0, DATEADD( YEAR, -2, GETDATE())), 0), 126), 'T', ' ')

  • RE: Delete Row from one table if other table with multiple rows meet the condition

    Hi,

    Try with this code

    delete from tableA where ConsumerID in(

    select ConsumerID from tableB where ConsumerID not in(

    select ConsumerID from tableB

    where DeleteFlag = 0))

  • RE: Blocking SPID with Text Data?

    SrcName (10/3/2013)


    create table #temp

    (

    spid smallint ,

    ecid smallint , ...

  • RE: Blocking SPID with Text Data?

    Hi,

    This query will give two rows one is with running (blocking)

    and other one is suspended (blocked)

    SELECT r.session_id,

    s.host_name,

    s.login_name,

    s.original_login_name,

    r.status,

    r.command,

    r.cpu_time,

    r.total_elapsed_time,

    t.text as Query_Text

    FROM sys.dm_exec_requests r

    ...

  • RE: Blocking SPID with Text Data?

    This script provide query and SPID of blocking and SPID and blocked SPID.

    and gives the blocking object name

    SELECT

    tl.request_session_id,

    wt.blocking_session_id,

    OBJECT_NAME(p.OBJECT_ID) BlockedObjectName,

    tl.resource_type,

    h1.TEXT AS RequestingText,

    h2.TEXT AS BlockingTest

    FROM sys.dm_tran_locks AS tl

    INNER JOIN sys.databases db ON...

  • RE: Change Excel formula to Case Statement

    By mistaken two times posted the same.

  • RE: Change Excel formula to Case Statement

    This can be achieved using CTE

    declare @person table (PersonID int, ApptDate datetime, ApptStatus varchar(10), NoOfAppts int, OneStopOrNot VARCHAR(10))

    insert into @person (PersonID, ApptDate, ApptStatus, NoOfAppts) values

    (49820,'07-09-2013','Seen',1),

    (49827,'12-sep-2013','Seen',1),

    (49831,'07-sep-2013','Seen',1),

    (49834,'07-sep-2013','Seen',1),

    (50084,'07-sep-2013','Seen',1),

    (50097,'05-sep-2013','Seen',1),

    (50172,'05-sep-2013','Seen',1),

    (50172,'27-sep-2013','Seen',2),

    (50175,'05-sep-2013','Seen',1)

    ;WITH persons AS (

    SELECT

    ...

  • RE: Change Excel formula to Case Statement

    Hi,

    This can be achieved using CTE

    declare @person table (PersonID int, ApptDate datetime, ApptStatus varchar(10), NoOfAppts int, OneStopOrNot VARCHAR(10))

    insert into @person (PersonID, ApptDate, ApptStatus, NoOfAppts) values

    (49820,'07-09-2013','Seen',1),

    (49827,'12-sep-2013','Seen',1),

    (49831,'07-sep-2013','Seen',1),

    (49834,'07-sep-2013','Seen',1),

    (50084,'07-sep-2013','Seen',1),

    (50097,'05-sep-2013','Seen',1),

    (50172,'05-sep-2013','Seen',1),

    (50172,'27-sep-2013','Seen',2),

    (50175,'05-sep-2013','Seen',1)

    ;WITH persons AS...

  • RE: using case when condition in WHERE in SP

    parulprabu (9/30/2013)


    Hi,

    Try with this code

    where id=@id and month=@month and Eid=

    case when @Eid=0 then case when Eid>0 then Eid else 0 end else @Eid end =Eid

    Sorry for the erroneous solution given....

  • RE: Update script

    Sean Pearce (9/30/2013)


    kapil_kk (9/30/2013)


    SrcName (9/30/2013)


    can you put your code in more details?

    What are these T.labeltext , T.LabelKey, T.FileID.

    error message is clear

    SELECT 'UPDATE table_1 T

    SET labeltext ='+ T.labeltext

    'WHERE LanguageID...

  • RE: using case when condition in WHERE in SP

    Hi,

    Try with this code

    where id=@id and month=@month and Eid=

    case when @Eid=0 then case when Eid>0 then Eid else 0 end else @Eid end =Eid

  • RE: Need help with Charindex function..

    Hi,

    Use this script

    DECLARE @test-2 VARCHAR(500)

    SET @test-2 = 'my email is Test@email.com.au how do i capture just the email'

    SELECT REVERSE(SUBSTRING(REVERSE(@test),CHARINDEX('@',REVERSE(@test))+1,CHARINDEX(' ',REVERSE(@test),CHARINDEX('@',REVERSE(@test)))-CHARINDEX('@',REVERSE(@test))))

    +SUBSTRING(@test,CHARINDEX('@',@test),CHARINDEX(' ',@test,CHARINDEX('@',@test))-CHARINDEX('@',@test))

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