Forum Replies Created

Viewing 15 posts - 1,231 through 1,245 (of 2,458 total)

  • RE: How to avoid using scalar User Defined Functions?

    Kim Crosser (9/29/2015)


    Alan.B (9/28/2015)

    Alan - minor issue, but the first two fields (CC, NPA) are actually Int values. Making them Varchar(5) introduces some additional overhead in the function, 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: How to avoid using scalar User Defined Functions?

    Ed Wagner (9/29/2015)


    Alan.B (9/28/2015)


    Ok, let's do an 800,000 row test.

    Nice test, Alan. I kinda knew how it would turn out, but it was nice to see it done.

    Alan.B (9/28/2015)


    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

  • RE: Order of predicates

    Luis Cazares (9/24/2015)


    GilaMonster (9/24/2015)


    Alan.B (9/24/2015)


    Just as a side note, this won't fail:

    WITH X AS

    (

    SELECT fld

    FROM #t

    WHERE cast(fld as int) > 0

    )

    SELECT fld

    FROM X

    WHERE ISNUMERIC(fld) =1

    Since the optimiser pushes...

    "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: Wildcard Searches

    Luis Cazares (9/29/2015)


    Alan.B (9/29/2015)


    Great article Luis! Informative, to the point. I picked up a couple things.

    Interesting technique using REPLICATE, I would add that I like to use ...

    "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: Wildcard Searches

    Great article Luis! Informative, to the point. I picked up a couple things.

    Interesting technique using REPLICATE, I would add that I like to use CHAR() more often...

    "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: What are the primary measures you look at, when performance tuning?

    Above all, how long it takes for the query to complete. Reads (something you can get using extended events or SET STATISTICS IO ON). I look at the query plan...

    "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: Are you a Data Scientist?

    I know and work with people who would be considered "true" data scientists as well as some aspiring data scientists. The consensus seems to be, based on what I've read...

    "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: How to avoid using scalar User Defined Functions?

    Kim Crosser (9/28/2015)


    Jeff Moden (9/28/2015)


    Kim Crosser (9/28/2015)


    On the other hand, UDFs used to do some fancy formatting of an output result value aren't likely to have any significant impact on...

    "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: Order of predicates

    Just as a side note, this won't fail:

    WITH X AS

    (

    SELECT fld

    FROM #t

    WHERE cast(fld as int) > 0

    )

    SELECT fld

    FROM X

    WHERE ISNUMERIC(fld) =1

    "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: Help me with the SYNTAX for the DELETE statement

    using the same sample data from above and taking Luis' solution you can also do this:

    WITH T AS

    (

    SELECT T.*

    FROM @t T

    WHERE NOT...

    "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: Help me with the SYNTAX for the DELETE statement

    This is just fine

    DECLARE @t TABLE (memberID int);

    DECLARE @m TABLE (memberID int);

    INSERT @m VALUES (1),(2),(4);

    INSERT @t VALUES (1),(2),(3),(4);

    SELECT * FROM @t;

    DELETE T

    FROM @t T

    LEFT JOIN @m M on T.memberID =...

    "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: Pivot, NestedPivot, unPivot?

    Luis beat me too it, I came up with the same crosstab solution that he did (his 1st query). I wanted to add that, as long as there are no...

    "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 Query

    martyres (9/24/2015)


    I need to complicate this a bit more accurately to the data. Also assume that there are sometimes, only single entries existing already......and I do NOT want them...

    "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: Choosing values

    I have personally found CHOOSE to be completely worthless. I have never seen an article or example of where CHOOSE was better than the alternatives. It's slow. I just don't...

    "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: Choosing values

    Ed Wagner (9/23/2015)


    Alvin Ramard (9/23/2015)


    Luis Cazares (9/23/2015)


    Manic Star (9/23/2015)


    patricklambin (9/23/2015)


    Stewart "Arturius" Campbell (9/22/2015)


    Interesting question, thanks Steve

    Another of the functions copied from Excel.

    I don't think so. These functions have been introduced...

    "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,231 through 1,245 (of 2,458 total)