Forum Replies Created

Viewing 15 posts - 3,556 through 3,570 (of 7,614 total)

  • RE: How to query with this date format ?

    WHERE column_name LIKE '1[67]-Nov-2017%' /* or '%1[67]-Nov-2017%' if the column doesn't start with the day */

  • RE: Get difference between dates year by year

    Edit: Sorry about the formatting.  The site automatically "adjusts" (corrupts!) multiple spaces into fewer spaces.


    SELECT start_date, end_date,
      CASE WHEN start_date >= '20140101' OR...

  • RE: Calculating sum of days/weeks

    It's wasteful to store monthly, quarterly and yearly data in a daily table (actually, it's wasteful to store days in a year anywhere, since your year is a calendar year). ...

  • RE: Trigger insert

    TheSQLGuru - Tuesday, February 6, 2018 3:55 PM

    Ahh, an extra de-reference. Works for me.

    I never expect compression to be available though because...

  • RE: Trigger insert

    TheSQLGuru - Tuesday, February 6, 2018 1:15 PM

    ScottPletcher - Tuesday, February 6, 2018 10:03 AM

  • RE: Trigger insert

    TheSQLGuru - Tuesday, February 6, 2018 8:03 AM

    ScottPletcher - Monday, February 5, 2018 3:26 PM

  • RE: Trigger insert

    TheSQLGuru - Friday, January 26, 2018 2:08 PM

    Wait - am I seeing correctly that your sproc actually creates the log record? If...

  • RE: Help me with the SELECT statement please ?

    That's an Itzik Ben-Gap "Gaps and Islands" query.  Sorry, I don't have time now to fully flesh it out, but someone should come along shortly who can.

  • RE: Query - Performance between dates

    What is the underlying table clustered on?  If it's clus on identity, you should seriously consider clustering instead by date first, esp. if you (almost) always look up by date,...

  • RE: Sequential 'Alter Table' queries

    I don't get any syntax errors.  That error must be because of some text/code before or after the main code.

    But you will likely get exec errors, since the...

  • RE: Views based on Multiple tables causing Locks?

    Btw, you might want to seriously consider using "UNION ALL" there rather than UNION.  I think you are going to force a massive sort of all the rows by using...

  • RE: Need counts of orders per week grouped by week

    You're welcome!  I'm very glad it helped.

  • RE: Need counts of orders per week grouped by week


    SELECT DATEADD(DAY, -DATEDIFF(DAY, 0, [Order Date]) % 7, [Order Date]) AS [Week of],
      COUNT(*) AS Count
    FROM dbo.your_table_name
    GROUP BY DATEADD(DAY, -DATEDIFF(DAY, 0, [Order Date]) %...

  • RE: Log file management after one off Query

    You should pre-allocate enough log space to handle the request.  The alter should be much faster if the log does not have to dynamically expand.  You should do the expansion in...

  • RE: Index rebuild - fail scenario

    You should only rebuild a 60GB index if and when you have a really, really compelling reason.

    I'd suggest specifying "SORT_IN_TEMPDB = ON" for large rebuilds, unless you have...

Viewing 15 posts - 3,556 through 3,570 (of 7,614 total)