Forum Replies Created

Viewing 15 posts - 1,711 through 1,725 (of 2,462 total)

  • RE: Splitting a field in the middle ??

    These problems are fun. If the data format is always the same (##/##/####) you could also do this:

    DECLARE @TestString VARCHAR(50)

    SET @TestString = 'LastName, FirstName (DOB: 01/01/1900)'

    SELECT SUBSTRING(@TestString, PATINDEX('%[0-1][1-9]/%', @TestString),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: Inline vs. Multi-Statement Table-Valued function, Temp Tables vs. CTEs?

    Had a second to kill. I put together a test to demonstrate why multi statement TVFs (mTVF) are terrible

    Using TempDB (a DB I know you have) this code will create...

    "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: Microsoft and R

    Great article. There is a good article about this at on SQLMag.com. This is huge news indeed and is all the rage where I work.

    "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: Hide field from Tablix based on query field valu

    PSB (3/18/2015)


    Hi,

    I have a report where there are fields like Field1,Field2,Field3,Field4 etc . In the report query there is a field named IsParentAccount . If it is 0 then I...

    "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: Stairway to Advanced T-SQL Level 3: Understanding Common Table Expressions (CTEs)

    arthur.bekker (3/18/2015)


    I think anyone who wants to use CTEs should read this article http://sqlblogcasts.com/blogs/tonyrogerson/archive/2008/05/17/non-recursive-common-table-expressions-performance-sucks-1-cte-self-join-cte-sub-query-inline-expansion.aspx....

    I showed the Execution Plan to this guy and he said that he wanted to "concrete" his...

    "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: Inline vs. Multi-Statement Table-Valued function, Temp Tables vs. CTEs?

    Katerine459 (3/18/2015)


    So, I've been reading the discussion on the latest Stairway article about CTEs (http://www.sqlservercentral.com/Forums/Topic1660966-34-1.aspx), and a bunch of people are talking about how CTEs are performance hogs. And now...

    "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: Stairway to Advanced T-SQL Level 3: Understanding Common Table Expressions (CTEs)

    jhood (3/18/2015)


    The recursive cte should never be used if you are concerned with performance.

    The recursion resolves row by row instead of sets. A while loop with temp tables...

    "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: Stairway to Advanced T-SQL Level 3: Understanding Common Table Expressions (CTEs)

    g.britton (3/18/2015)


    One other nice use: CTE as target table

    You can write this:

    WITH CTE AS

    (

    SELECT somecolums,....

    FROM sometable

    WHERE...

    "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: Stairway to Advanced T-SQL Level 3: Understanding Common Table Expressions (CTEs)

    chris.puncher (3/18/2015)


    Just worth pointing out that CTEs against large tables can be very slow; something I have had first hand experience of.

    Here is an alternative method that proved much more...

    "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: Stairway to Advanced T-SQL Level 3: Understanding Common Table Expressions (CTEs)

    Great article. One correction however:

    Emphasis mine...

    Below are some clauses that can't be used in a CTE:

    ORDER BY (unless used with TOP clause)

    INTO

    OPTION clause with query hints

    FOR XML

    FOR BROWSE

    Not true... You...

    "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: Need help with running total with thresholds

    Had a few moments to kill... Here's an example of how to solve this using the link that I provided.

    Note that I don't understand where, in row 1 of...

    "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: Need help with running total with thresholds

    This article should help:

    Solving the Running Total and Ordinal Rank Problems[/url]

    "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: IN vs EXISTS

    This is a very good article on this subject:

    http://sqlinthewild.co.za/index.php/2009/08/17/exists-vs-in/[/url]

    "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: Update incoming rows based on % calculation

    Here's a solution.

    I'm sure there is an easier way but this is a cursor/loop-free way that will work.

    /*Assumptions

    (1) There are alway 2 product names that are equal...

    "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: Update incoming rows based on % calculation

    I have a solution but need a little clarification...

    What exactly do you mean by

    Amount = or (within +/- 5%) of Amount

    For example, Let's say Amount1 is 1051 and...

    "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 - 1,711 through 1,725 (of 2,462 total)