Forum Replies Created

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

  • RE: Cursor in SQl Server

    There is a side note to the cursor solution, each pass (a single record from the restrictions table) is applied to the inventory records in a set based fashion. ...

  • RE: Cursor in SQl Server

    Well, unfortunately, I do know of a case where a cursor is the best option (at least at the time). Last employer we had a restrictions table for documents...

  • RE: Help with Year calculations

    I have to agree with Jack. Use the correct data type for the correct data element. I agree, unless you really need to record the time of birth,...

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

    Great!!

    😎

  • RE: Cursor in SQl Server

    Cursors may be evil, but they may be a necessary evil. Where possible use set based solutions, but sometimes you may find cursors are necessary, and therefore knowing how...

  • RE: Help with Year calculations

    Jeff Moden (3/10/2008)


    Lynn Pettis (3/10/2008)


    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...

  • 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

    😎

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