Forum Replies Created

Viewing 15 posts - 5,581 through 5,595 (of 6,036 total)

  • RE: Trigger to compare incoming record w/ previous record

    Another mistake in your trigger:

    You check IF EXISTS ... and insert whole set of lines, even not al of them are in this EXIST set.

    It should be like this:

    Insert Into...

  • RE: easier way??

    Agree with Daryl.

    If you code any knowledge you definitely do something wrong.

    You need to put all values in database and reference it in your code.

  • RE: Help with Time Duration

    It's even more simple than you can imagine:

    Logout - Login

    If you need it for presentation purposes:

    convert(varchar(8), Logout - Login, 108)

     

  • RE: ASCII character 0

    REPLACE (<ColName>, CHAR(0), '')

  • RE: age in char format

    And actually it's not right.

    It's good for partial year calculations (say, 75.3 year) not for days.

    Right one is here:

    Select DateBirth, cast (Years as varchar(3)) + ' Years, '

     + cast(Months +...

  • RE: age in char format

    Full script I used for my test:

    DECLARE @Table TABLE (

     Datebirth datetime )

    INSERT INTO @Table

    SELECT '1950-02-21'

    Select Getdate(), DateBirth, AGE, cast (datepart(YY, AGE)-1900 as varchar(3)) + ' Years, ' 

     + cast(datepart(mm,...

  • RE: Simple join query question

    You need another table:

    JobTitle, Paycode.

    Record known relations between those entities into this table and use it in your join.

  • RE: Searching a varchar column with multiple wildcards

    Same script but no loops:

    SELECT CourseID, LongTitle, SUBSTRING(CourseDesc, 1, 50), 0, '', 19000101, 19000101

          FROM dbo.Course C

          INNER JOIN @CourseDescArray A on C.CourseDesc LIKE '%'+A.Element+'%'

         GROUP BY CourseID, LongTitle, SUBSTRING(CourseDesc, 1, 50)

  • RE: covert numeric (19,5) to string (10,4)

    Check out "STR function" in BOL

  • RE: age in char format

    Sorry, forgot to remove "@"

  • RE: age in char format

    Select Getdate(), DateBirth, AGE, cast (datepart(YY, AGE)-1900 as varchar(2)) + ' Years, ' 

     + cast(datepart(mm, AGE)-1 as varchar(2) ) + ' Months, '

     + cast(datepart(dd, AGE)-case when DateBirth < '2000-03-01'...

  • RE: Number of Mondays between two dates

    Sorry, I was looking on another your formula.

  • RE: GROUP BY help with datetime criteria

    Add computed column "ShiftNo" to you column and calculate shift number from time recorded.

    Then you can apply

    GROUP BY ShiftNo.

  • RE: Number of Mondays between two dates

    And you formula returns 1 Monday between '2005-02-19' and '2006-02-20' and between '2006-02-20' and '2006-02-21'.

    This Monday is included in both periods. Sounds not right.

  • RE: Number of Mondays between two dates

    What about server collation?

Viewing 15 posts - 5,581 through 5,595 (of 6,036 total)