Forum Replies Created

Viewing 15 posts - 25,111 through 25,125 (of 26,484 total)

  • RE: Maintenance Plan fails on 1 of 5 user databases

    There is possibly an error report somewhere (no I don't know where or its name other than it probably ends in the extension of .txt).

    One possiblity here from what I...

  • RE: Maintenance Plan fails on 1 of 5 user databases

    Could you provide the full text of the error message? With all ...'s it is hard to know what the error actually is.

    Thanks

    😎

  • RE: Help with Year calculations

    DECLARE @ConsultantID VARCHAR(20)

    DECLARE @StartDate datetime

    DECLARE @EndDate datetime

    DECLARE @Year CHAR(4)

    SET @ConsultantID = '0000003'

    SET @StartDate = NULL

    SET @EndDate = NULL

    SET @Year = 2007

    -- IF @Year <> NULL

    -- ...

  • RE: Best Way to Calculate Age

    The people you know who celebrate their birthdays on Feb 28 on non-leap years, doesn't mean the state or country they live in says they are another year older yet....

  • RE: Help with Year calculations

    Jeff, since the OP wants the end of the year wouldn't you want this:

    SELECT @startdate = CAST('2007' AS DATETIME)

    SELECT @enddate = DATEADD(yy,1,CAST('2007' AS DATETIME)) - 1

    I know why you do...

  • RE: Best Way to Calculate Age

    If there is a way to do this without comparing months and day, I just can't find on my and I haven't the energy to search all these posts. ...

  • RE: Best Way to Calculate Age

    GSquared, don't think so. Please doupbe check this code snippet to be sure I have your code right:

    declare @dob datetime,

    @calcDate datetime

    set...

  • RE: Best Way to Calculate Age

    How about this:

    datediff(yy, @dob, @calcDate) - case when (@calcDate < dateadd(yy, datediff(yy, @dob, @calcDate), @dob)) then 1 else 0 end as AgeInYears

    Tests:

    declare @dob datetime,

    ...

  • RE: Best Way to Calculate Age

    I did say appears to work. That was the leap year test I was missing. thanks

    😎

  • RE: Best Way to Calculate Age

    Here is a formula that appears to work okay in SQL Server:

    datediff(yy, @dob, @calcDate) - case when (datepart(dy, @calcDate) < datepart(dy, @dob)) then 1 else 0...

  • RE: Do I need a CURSOR?

    I will add this to the issue at my previous employer: it was an inherited system (was supported by an outside company and brought internal) that was written entirely in...

  • RE: Do I need a CURSOR?

    If discounts have to be applied in a specific order, it does add to the complexity. Ten percent off of ten percent off, is not twenty percent off:

    x =...

  • RE: Do I need a CURSOR?

    Cursors may be evil, but they are sometimes a necessary evil. I have seen where a cursor based solution out performed a set based solution. Having learned more...

  • RE: SELECT Statement Question

    Jeff Moden (3/7/2008)


    I'll throw in that just from a code consistency standpoint, WHERE IN should be rewritten to a normal INNER JOIN like Lynn wrote it.

    Thanks, Jeff. You should...

  • RE: SELECT Statement Question

    The subquery is identifying the CategoryID for the specified CategoryName, 'Beverages', so that the main query only returns products for that specified category.

    Another way to write that query is as...

Viewing 15 posts - 25,111 through 25,125 (of 26,484 total)