Forum Replies Created

Viewing 15 posts - 106 through 120 (of 149 total)

  • RE: Bones of SQL - Practical Calendar Queries

    I rewrote it yet again, without case or firstdate:

    CAST (DATEADD(WEEK, ABS(( DATEDIFF(WEEK, '20161009', DATEADD(DAY, -1, o.modify_date))

    + 1 ) % 2), DATEADD(DAY, ( DATEPART(WEEKDAY, DATEADD(DAY, -1, o.modify_date))

    - 7 )...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: does following query needs union or using cases/isnull/coalace will do.

    rajemessage 14195 (10/16/2016)


    1)

    the real situation was quite tipical, they where entering records in both tables #i and #j and

    wanted to give priority to #i

    because when they where entering record first...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: How to get full name of the employer by getting rid of null values in between

    SELECT ID ,

    RTRIM(CONCAT(s.FirstName + ' ', s.MiddleName + ' ', s.LastName)) AS FullName

    FROM #something AS s;

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Bones of SQL - Practical Calendar Queries

    ScottPletcher (10/17/2016)


    Rather unfair to cut off the part where I asked what specifically are your requirements, because you've never stated them clearly, and then to blast me for not meeting...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Bones of SQL - Practical Calendar Queries

    ScottPletcher (10/14/2016)


    If you just want a list of Sunday dates that are two weeks apart from a given starting date:

    SELECT COUNT(*),

    DATEADD(DAY,...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Bones of SQL - Practical Calendar Queries

    First day of the business week is Monday.

    What do you recommend?

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Bones of SQL - Practical Calendar Queries

    You made me curious and its been a quiet day.

    SELECT COUNT(*),

    CAST(DATEADD(WEEK, DATEDIFF(WEEK, '20061231', DATEADD(DAY, 7

    - CASE DATEPART(WEEKDAY, o.modify_date) WHEN 1...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Bones of SQL - Practical Calendar Queries

    ScottPletcher (10/14/2016)


    Wow, that's a fascinating statement. Computers are known for doing billions of certain mathematical calcs per second (graphics chips hit trillions). Under no circumstances I know of...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Conversion failed when converting the nvarchar value 'NONE' to data type int.

    In case you wanted to know why Sergiy's answer is correct, your IN clause listed integer values (no quotes), even though the column is defined as a character string. ...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Bones of SQL - Practical Calendar Queries

    ScottPletcher (10/13/2016)


    I don't see how that would be the case. Couldn't you just use simple math to calc the pay periods, then join to the pre-calc'd dates? How...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Bones of SQL - Practical Calendar Queries

    Another benefit to using the calendar table rather than the Select DateAdd, performance is much better when used for filtering/grouping.

    One request I received at my work was to see all...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Synch 2 tables; performance

    Is it possible for a row to be in tblDst, but not in tblSrc? There was no mention of any action for that situation so I'm assuming you would still...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Synch 2 tables; performance

    I'm curious what they mean by impact. The bridge table would be fairly light-weight and incur minimal locking. It may even be safe to use With (NoLock) to...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Error converting data type nvarchar to float

    To check which records will not convert to float:

    1. Import the spreadsheet with all columns as nvarchar(255).

    2. Add a new float column to the table after populated

    3. Update float column...

    Wes
    (A solid design is always preferable to a creative workaround)

  • RE: Synch 2 tables; performance

    Create a bridge table containing a column for the primary key and a column for a left/right bit indicator.

    Insert into the bridge table the exception records from each side, with...

    Wes
    (A solid design is always preferable to a creative workaround)

Viewing 15 posts - 106 through 120 (of 149 total)