Forum Replies Created

Viewing 15 posts - 3,436 through 3,450 (of 7,609 total)

  • RE: Calculating Date Difference

    David Burrows - Tuesday, April 24, 2018 6:40 AM


    SELECT
    DATEDIFF(day, COALESCE(date0,dateStart),date1),
    DATEDIFF(day, COALESCE(date1,date0,dateStart),date2),
    DATEDIFF(day, COALESCE(date2,date1,date0,dateStart),date3),
    DATEDIFF(day, COALESCE(date3,date2,date1,date0,dateStart),date4),
    DATEDIFF(day, COALESCE(date4,date3,date2,date1,date0,dateStart),date5),
    DATEDIFF(day, COALESCE(date5,date4,date3,date2,date1,date0,dateStart),date6),
    DATEDIFF(day, COALESCE(date6,date5,date4,date3,date2,date1,date0,dateStart),date7)
    FROM temp

    Nice, but I...

  • RE: Normalization

    sgmunson - Tuesday, April 24, 2018 6:15 AM

    DBA Live - Monday, April 23, 2018 4:30 PM

    April 24, 2018 at 7:53 am

    #1988019

  • RE: Normalization

    Yes.  Author and Publisher do not belong in the table shown.  I strongly doubt Edition or Media belongs there either.

    I'm not sure about Date.  I'm not sure how...

  • RE: Calculating Date Difference


    ;WITH cte_dates AS (
      SELECT t.*, dates2.*
      FROM temp t
      CROSS APPLY (
       SELECT
            MAX(CASE WHEN row_num =...

  • RE: Subquery as column

    You'll probably get exactly the same execution plan either way.

    But for ease of clarity, coding and maintenance, I'd write it this way:


    SELECT sf.org,...

  • RE: Transferring data between tables

    Again, the easiest solution is to simply split into two tables.

    You can even keep the original table name if you:
    1) Create the new table, with all the...

  • RE: break cluster and get sql server available

    I don't know about "broken", but if you "uncluster" it normally, it runs fine.

    And, yes, then you have two servers each running a single, separate, independent instance.

  • RE: break cluster and get sql server available

    Somewhat confusing:  "has ... active-active, active-passive setup".  Huh, can't be both at the same time, which is it?

    If A-P, I know we've undone/removed clustering and it worked fine,...

  • RE: Where Clause Logic

    JR11 - Thursday, April 19, 2018 9:05 AM

    ScottPletcher - Thursday, April 19, 2018 8:22 AM

  • RE: Where Clause Logic

    Difficult to tell exactly what you need, but if you want the other conditions to apply to "Developer" too, then do this:


    WHERE (customer = @customer_number)...

  • RE: Transferring data between tables

    richardmgreen1 - Thursday, April 19, 2018 4:06 AM

    ScottPletcher - Wednesday, April 18, 2018 9:27 AM

  • RE: Join on field of varying length

    daniness - Wednesday, April 18, 2018 1:59 PM

    Hi Scott,
    Thanks for your reply. I'm not following your code. In this portion:

  • RE: How to use Cast & Convert

    Use CAST (it's ANSI-standard), and CAST the final result as well, if you want a specific size of result:

    CAST( CAST( SUM(Principal1) AS DECIMAL(5,2) ) + CAST ( SUM(BankInterest) AS DECIMAL(5,2)...

  • RE: Join on field of varying length

    daniness - Wednesday, April 18, 2018 10:24 AM

    ScottPletcher - Wednesday, April 18, 2018 9:17 AM

  • RE: Determining the Years, Months, Weeks and Days between two dates

    See if this gives you what you need -- it should at least be very close.  Btw, T-SQL isn't like C#, you don't need separate statements for every calc.

Viewing 15 posts - 3,436 through 3,450 (of 7,609 total)