Forum Replies Created

Viewing 15 posts - 3,826 through 3,840 (of 4,087 total)

  • RE: Debugging Stored Procedure with looping cursor

    From what I understand, there is some overhead for every transaction. With a set-based query, this overhead is performed once; with a cursor, this overhead is performed for every...

  • RE: Help with TSQL Code

    I think I found the problem. Your original query was only grouping on the Customer Number, but you want to group on the Order Number as well. Otherwise...

  • RE: Help with TSQL Code

    You need to include a CASE statement in your HAVING clause.

    Select @constituency, o.customer_no

    , Count(l.per_no) AS AllPerf

    , COUNT(CASE p.season WHEN 165 THEN l.perf_no...

  • RE: SQL Days until Christmas

    Michael Valentine Jones (10/15/2010)


    selectDaysTillChristmas =

    datediff(dd,getdate(),dateadd(yy,datediff(yy,-1,getdate()),-7))

    But this will give you negative numbers from Dec. 26-31. Here is the modified code to always give you the NEXT Christmas.

    select DateDiff(Day, GetDate(), dateadd(yy,datediff(yy,-1,DateAdd(Day,...

  • RE: Arranging table output

    Maybe what you really want to do is create a view. That way you can use the trick of specifying the TOP (100) PERCENT, so that you can specify...

  • RE: Complex join

    This is exactly what the PIVOT operator was designed for. Check it out in BOL.

    That being said, using a crosstab is often more efficient.

    select datepart(ww, created) as Week,

    COUNT(CASE s.commonname...

  • RE: How to calculate a duplication rate?

    I think the best measure is probably

    (totalRecords - uniqueRecords)/totalRecords

    In your example that would give 75%. The hard part is, of course, identifying the unique records.

    Drew

  • RE: Impacts with frequent use of FOR XML RAW

    I don't see that how often it is executed has any bearing on the issue unless it starts blocking itself. I wouldn't immediately target the FOR XML as being...

  • RE: Impacts with frequent use of FOR XML RAW

    Eric1/2aB (10/14/2010)


    I am trying to make a case to have this code redesigned in a way that FOR XML is not needed.

    Do you have a personal vendetta against the FOR...

  • RE: OPENROWSET with parameters

    tyson.price (10/13/2010)


    Sorry about the formatting. I must have used the code tags wrong. 🙂

    The "/" only goes in the closing tag. You have it in both the opening...

  • RE: Need Records other than month end dates from a table

    ravimodi (10/12/2010)


    Thanks Craig...for your input. Well, I checked this and just wanted to discuss...basically the query u gave gives the month end records and what i need basically are the...

  • RE: Results contain multiples of balances when multiple tables are joined

    You beat me to it, but I'm posting mine anyhow, because there are some points that I wanted to address.

    WITH Charges AS (

    SELECT Account, Sum(qty*amount) AS Total_Charges

    FROM test_charges AS tc

    INNER...

  • RE: Check for field value before attempting to insert row

    Derrick Smith (10/12/2010)


    This part is the issue:

    AND (NOT email IN (SELECT email FROM failures))

    AND (NOT email IN (SELECT email FROM removes))

    AND (NOT email IN (SELECT email FROM contacts));

    I'd be willing...

  • RE: Check for field value before attempting to insert row

    aniccadhamma (10/12/2010)


    regarding DISTINCT... I tried a SELECT DISTINCT email, business statement, but it wanted both email and business together to be distinct. that's not what I want. ...

  • RE: CASE STATEMENT

    PSB (10/11/2010)


    I am using SSIS lookup transform to match an ID corresponding to the name.

    The condtition is if the "Name" comes in as NULL then the "ID" should be NULL

    Else...

Viewing 15 posts - 3,826 through 3,840 (of 4,087 total)