Forum Replies Created

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

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

    You forgot to change the WHERE to ON for the INNER JOIN

    Good catch John, thanks.

    Does anyone know why you shouldn't use CROSS APPLY for everything? Or does it sometimes come...

    "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

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

    Emph mine...

    ANSI-89 style may have been a standard back in the day, but has long been supplemented. In fact it returns incomplete sets. There used to be a page in...

    • This reply was modified 7 years, 1 months ago by Alan Burstein.
    • This reply was modified 7 years, 1 months ago by Alan Burstein. Reason: Changed WHERE to ON for INNER JOIN
    "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

  • Reply To: ssms crashes when editing .sql script

    I have this type of problem when I have too many SQL windows open or too much stuff running on my PC. The problem persists, often, even after closing the...

    "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

  • Reply To: Are the posted questions getting worse?

    My $0.02 about the new site...

    First, I miss the count of likes (for threads and individual comments). No nobody knows if you "liked" a thread or comment.

    As someone with articles...

    "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

  • 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

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