Forum Replies Created

Viewing 15 posts - 3,766 through 3,780 (of 4,087 total)

  • RE: Last 2 months Last working date

    SELECT Convert(varchar(25), Max(dt), 100)

    FROM #Temp

    WHERE DateDiff(Month, dt, Getdate()) BETWEEN 1 AND 2

    GROUP BY DateDiff(Month, dt, Getdate())

    ORDER BY Max(dt)

    I personally would return the dates in datetime format, rather than converting them...

  • RE: Calculating percentage issue

    Because they appear in the SELECT clause instead of the FROM clause the aliases a, b, and c are column aliases, but you are trying to treat a and b...

  • RE: Shredding XML - Need to Include OfferId

    pamozer (3/3/2011)


    I'm assuming the OP is me but what does it stand for? And I hadn't checked the actual data yet only the counts.

    OP is Original Poster.

  • RE: Shredding XML - Need to Include OfferId

    opc.three (3/3/2011)


    drew.allen (3/3/2011)


    opc.three (3/3/2011)


    Try this:

    SELECT b.value('(offerId)[1]', 'Int') AS [offer_id],

    fr.value('(internetPrice)[1]', 'decimal') AS [internet_price],

    fr.value('(newStandPrice)[1]', 'decimal')...

  • RE: Shredding XML - Need to Include OfferId

    opc.three (3/3/2011)


    Try this:

    SELECT b.value('(offerId)[1]', 'Int') AS [offer_id],

    fr.value('(internetPrice)[1]', 'decimal') AS [internet_price],

    fr.value('(newStandPrice)[1]', 'decimal') AS [news_stand_price],

    ...

  • RE: Shredding XML - Need to Include OfferId

    You're shredding the same document twice when you really don't need to, because you started from the highest relevant point in the document hierarchy and worked down, when you really...

  • RE: how grab text before a "-" character in a join

    Jeff Moden (3/2/2011)


    drew.allen (3/2/2011)


    Another option is to use the LIKE operator. I don't know which will perform better.

    SELECT *

    FROM TableA

    INNER JOIN TableB

    ON TableA.ID LIKE Cast(TableB.ID as varchar(11)) + '%'

    This...

  • RE: how grab text before a "-" character in a join

    Another option is to use the LIKE operator. I don't know which will perform better.

    SELECT *

    FROM TableA

    INNER JOIN TableB

    ON TableA.ID LIKE Cast(TableB.ID as varchar(11)) + '%'

    This assumes that the...

  • RE: Concatenating numeric fields

    Do you really want to return fiscal year plus calendar month rather than fiscal year plus fiscal period?

    I also dislike using a CASE statement to return the fiscal year, because...

  • RE: ERROR cursor:The cursor does not include the table being modified or the table is not updatable through the cursor.

    yoho23_2000 (2/22/2011)


    Is there anything obvious you can see

    Yes, you're using a CURSOR when you should be using a set-based approach. I can't tell you the exact set-based approach to...

  • RE: Detach trigger code

    What I've done in these cases is use a TRY/CATCH block leaving the CATCH block empty.

    BEGIN TRY

    EXEC msdb.dbo.sp_send_dbmail <your parameters here>

    END TRY

    BEGIN...

  • RE: Conditional Where statement

    The problem with your original CASE statement is that you were trying to return a Boolean value and T-SQL won't let you return a Boolean value. You can restructure...

  • RE: Nested Case Statement possible?

    You can also rewrite this using a single CASE statement, which is usually more succinct and therefore easier to follow.

    Select

    case when SO.CUSTOMER = R.CUSTOMER AND R.QUANTITY_REMAINING >= R.CUSTOMER_QTY_NOT_SHIPPED

    then...

  • RE: Need the Price with the Latest Date

    Jeff Moden (2/1/2011)


    drew.allen (1/31/2011)


    Craig Farrell (1/31/2011)


    After having done some other tests, this method seems to be the quickest, especially if you have a solid index on Item/ChangePriceDate

    My tests indicate the...

  • RE: Need the Price with the Latest Date

    Craig Farrell (1/31/2011)


    After having done some other tests, this method seems to be the quickest, especially if you have a solid index on Item/ChangePriceDate

    My tests indicate the opposite. I've...

Viewing 15 posts - 3,766 through 3,780 (of 4,087 total)