Forum Replies Created

Viewing 15 posts - 4,516 through 4,530 (of 10,144 total)

  • RE: Error on Subquery

    @nitha jen

    Please start a new thread for your issue. Hijacking other folks threads causes confusion. Thanks.

  • RE: using case in where clause having other conditions

    ssurekha2000 (6/12/2013)


    not fully understood

    using the above i am not getting any records

    but in query analyser i get 100 records with date condition & id condition

    Please provide more detail. Your query...

  • RE: using case in where clause having other conditions

    -- use APPLY to evaluate your filters

    SELECT *

    FROM table1

    CROSS APPLY (

    SELECT

    Filter1 = CASE

    WHEN @con = 0 AND YEARMONTH >= REPLACE(@YearMonth,'-','') THEN 1

    WHEN YEARMONTH <>...

  • RE: Simplifying The Stored Procedure

    Substitute each reference to the temp table #records with the actual query used to generate the temp table, then eliminate unnecessary table references. This takes you back to a "raw"...

  • RE: Odd Conversion Error

    STUFF() works nicely too:

    SELECT

    PhoneNumber,

    REPLACE(PhoneNumber,LEFT(PhoneNumber,5),''),

    STUFF(PhoneNumber,1,5,'')

    FROM (

    SELECT PhoneNumber = CAST('(999)4746641' AS VARCHAR(15)) UNION ALL

    SELECT '(718)4746641'

    ) d

    WHERE LEFT(PhoneNumber,5) = '(999)'

  • RE: Update Performance

    Alexander Suprun (6/7/2013)


    ChrisM@Work (6/7/2013)


    Something like this can help, and it's easy to check;

    UPDATE D SET

    Track_ID = P.Track_ID,

    Territory_ID = P.Territory_ID,

    Major = P.Major

    FROM Staging.Track_Play D

    INNER JOIN Staging.Track_Mapping P

    ON P.ISRC =...

  • RE: Update Performance

    Something like this can help, and it's easy to check;

    UPDATE D SET

    Track_ID = P.Track_ID,

    Territory_ID = P.Territory_ID,

    Major = P.Major

    FROM Staging.Track_Play D

    INNER JOIN Staging.Track_Mapping P

    ON P.ISRC = D.ISRC_Code

    AND P.Event_Date =...

  • RE: prevent simultaneous update

    You might consider something like this too:

    DECLARE @TaskID INT

    UPDATE TaskTable SET

    TaskStatus = 2,

    TaskOwner = @user-id,

    Assigned = 1, -- don't forget

    @TaskID = TaskID -- collect TaskID for client

    WHERE TaskID =...

  • RE: Inline Table Valued Function

    Sean Lange (6/6/2013)


    ... In lieu of using a permanent table I use a view that creates the tally table on the fly. 0 reads to access it and I don't...

  • RE: APPLY versus ROW_NUMBER versus double JOIN to retrieve most recent record from a foreign key table

    SELECT

    sh.ServicerHistoryId,

    shrc.CommissionRate

    FROM dbo.ServicerHistory sh

    OUTER APPLY (

    SELECT

    d.CommissionRate

    FROM (

    SELECT

    ishrc.CommissionRate,

    RowNum = ROW_NUMBER() OVER (PARTITION BY ServicerHistoryID ORDER BY EffectiveDate DESC)

    FROM dbo.ServicerHistoryCommissionRate ishrc

    WHERE ishrc = ServicerHistoryID = sh.ServicerHistoryID

    ) d

    WHERE d.Rownum = 1

    )...

  • RE: APPLY versus ROW_NUMBER versus double JOIN to retrieve most recent record from a foreign key table

    Matthew Darwin (6/6/2013)


    ...

    Any tips, pointers or observations are most welcome!

    Have you tried using the row_number method with the outer apply so you have an even playing field?

  • RE: Issue while joining two tables with no unique columns

    A long time ago in a galaxy far, far away a bunch of folks were arguing about an exotic and rarely-mentioned internal feature of SQL Server for Pangaians 238857. The...

  • RE: Brain lock...

    jconaty54 (6/6/2013)


    I have a table with schema that looks like this

    Year, Jan, Feb, Mar, Apr, May,June, July, Aug, etc...

    The report calls for the month selected plus 3 months back. This...

  • RE: Are the posted questions getting worse?

    rodjkidd (6/6/2013)


    Anybody from the thread heading to SQL Saturday Edinburgh?

    I'm flying up tonight. Looks like the weather will be good - even though I'll be indoors most of the time!...

  • RE: Building a new server

    Are you the adminstrator of the SQL server instance, Mike?

Viewing 15 posts - 4,516 through 4,530 (of 10,144 total)