Forum Replies Created

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

  • Reply To: Learning a New Language

    I've been late to the AI party. Everyone I work with uses Copilot, I just starting playing with it - I don't have an opinion yet.

    I love Grok, it has...

    "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: From each string, extract numbers following a '#' and create separate row

    Jeff Moden wrote:

    Alan... you might want to explain what the bernieML.samd. stuff is.

    Thanks Jeff - I fixed my code. I was using my own DB and forgot to remove 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: From each string, extract numbers following a '#' and create separate row

    UPDATED 10/31/2024

    The was an error in my code, I just changed  "bernieML.samd.ngrams8K" to "dbo.ngrams8K". I was using code from my own DB (BernieML) with a different schema (samd).


    @sqlrookie-2

    Sorry for...

    "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: Data cleansing/conversion tool HPE

    There's always MS Data Quality Services (DQS). It allows for data cleansing, matching, de-duplication and an array of related data quality services. It's not easy to use but does...

    "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: From each string, extract numbers following a '#' and create separate row

    For this you can use a "splitter" (AKA "tokenizer" function.)

    DECLARE @String VARCHAR(8000) = 'Hello world. #1234 has been replaced by #014521';

    SELECT SomeNbr = REPLACE(split.[value],'#','')
    FROM STRING_SPLIT(@String,' ') 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

  • Reply To: From each string, extract numbers following a '#' and create separate row

    Post got submitted twice. Sorry.

    • This reply was modified 1 years, 7 months ago by Alan Burstein. Reason: Dupe
    "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: T-SQL Requires the Right Approach

    Another problem I’ve seen frequently is the overuse of user-defined functions (UDFs), especially nesting scalar UDFs.

    scalar UDFs, nested or not, tend to burn the house down.  When used in 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

  • Reply To: How To Find A Perfect Match

    Glen - I love this article. Amazing stuff. I read some of it and skimmed the rest but can't wait until I have time to play with your code 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

  • Reply To: "Number of rows Read" vs "Actual Number of rows for all Executions"

    Thanks for the replies and sorry for being a Ghost OP.

    To me, the above makes sense based on the wording of those metrics and is useful information.  Does the above...

    "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: How to update generated number field with number to every group from 1 to 4 ?

    Adi did it like I would. His excellent solution could be simplified as

    SELECT t.FamilyID, t.PortionKey, t.GroupID, GeneratorNumber = 
    ...
    "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: Need help in rewriting this query to improve performance

    I would write it using EXISTS instead of INs. It's easier if you use table aliases.

    I always use EXISTS instead of IN. Best case - it performs better, worse case...

    "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: XML Parsing Problem

    Note that the "./" in your code is not required based on the XML Context. Also note that specifying that you need the elements' text, via text(), will improve performance.

    For...

    "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: Cant cast VARCHAR(MAX) To XML Variable

    To better understand the problem and solution have a look at Well Formed XML:

     

    "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: Complex .Json Data Parsing with multiples Array elements into SQL (MS-SQL 2016)

    This is my first time messing with JSON in SQL. The BOL entry on this helped me.

    First, JSON is cases sensitive so, $.Data is not the same as $.data. Next,...

    "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: Last day of the previous month - Format MM/DD/YYYY

    As Jeff mentioned, CONVERT + 101 gets you the formatting you need:

    SELECT CONVERT(VARCHAR(10), GETDATE(), 101);

    For the last day of the previous month:

    SELECT EOMONTH(DATEADD(MONTH,-1,GETDATE()));

    For 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

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