Forum Replies Created

Viewing 15 posts - 61 through 75 (of 2,458 total)

  • Reply To: Current day from current week of the year

    I would do something like this:

    DECLARE @date DATETIME = getdate();

    SELECT WeekStart = CAST(DATEADD(DAY,f.Dt+1, @date) AS date),
    WeekEnd = CAST(DATEADD(DAY,f.Dt+8, @date) AS date)
    FROM (VALUES(DATEPART(WEEKDAY,@date)-1)) AS w(Wd)
    CROSS APPLY (VALUES(-IIF(w.Wd=0,7,w.Wd))) AS...
    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: The "Numbers" or "Tally" Table: What it is and how it replaces a loop.

    Jeff Moden - Friday, March 8, 2019 9:33 AM

    Alan.B - Thursday, March 7, 2019 7:50 PM
    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: The "Numbers" or "Tally" Table: What it is and how it replaces a loop.

    Luis Cazares - Thursday, March 7, 2019 6:32 PM

    Jeff Moden - Thursday, March 7, 2019 4:12 PM

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: DigitsOnlyEE and AlphaNumericOnly

    TheSQLGuru - Wednesday, March 6, 2019 5:51 PM

    Should this (and PatExclude8K/PatReplace8K,et al) have Paul White's ORDER BY bug fixes put in place?

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: The "Numbers" or "Tally" Table: What it is and how it replaces a loop.

    drew.allen - Thursday, March 7, 2019 8:49 AM

    Jeff Moden - Thursday, March 7, 2019 6:39 AM
    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Slow running Stored Procedure when using Date Parameters

    dukesbrent - Monday, February 25, 2019 2:47 PM

    Here is the code for the UDF:

    CREATE FUNCTION [dbo].[fn_Get_Date_Params]
    (
        @strPeriod varchar(254),
        @dtmStart_Date datetime,
        @dtmEnd_Date datetime,
        @dtmGetDate datetime,
        @intWhichOne...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: removed zeroes from numeric column

    Super easy when using string functions (of course) but, for fun, I took a stab at this. It's a little harder when the number is not evenly divisible by 10...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Learning about DML Triggers

    Good article Steve. Succinct and informative.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: SQL Server Trace Flags - Complete list

    This article is awesome! Thanks for putting it together.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Offsite backups

    muthukkumaran Kaliyamoorthy - Wednesday, February 13, 2019 1:42 AM

    Alan.B - Tuesday, February 12, 2019 12:52 PM
    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Offsite backups

    Beatrix Kiddo - Wednesday, February 13, 2019 1:30 AM

    I think adding your jurisdiction/location/retention requirements and any other regulatory considerations might help others...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Using Computed Columns

    Good article and great topic. I'm a big fan of computed columns so it's nice to see a detailed article on the topic. I would warn, however, against using a...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Nasty Fast N-Grams (Part 1): Character-Level Unigrams

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Sort already comma separated list

    Jeff Moden - Friday, February 8, 2019 3:27 PM

    Alan.B - Friday, February 8, 2019 2:49 PM
    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Find and replace third occurrence of the string

    saravanatn - Monday, February 11, 2019 10:09 AM

    Alan.B - Monday, October 22, 2018 3:19 PM

    Just...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 61 through 75 (of 2,458 total)