Forum Replies Created

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

  • RE: Sorting and Adding to a table based on conditions

    Got it. Note the mild tweak:

    DECLARE @sample TABLE (col1 varchar(100), col2 varchar(100), col3 varchar(100), col4 int);

    INSERT @sample VALUES

    ('1234', 'ABC', 'TEXT', '80'),

    ('1234', 'ABC', 'TEXT2', '20'),

    ('1234', 'XYZ', 'TEXT',...

    "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: Sorting and Adding to a table based on conditions

    Here's an example of how you could tackle this:

    DECLARE @sample TABLE (col1 varchar(100), col2 varchar(100), col3 varchar(100));

    INSERT @sample VALUES

    ('1234 ABC', 'TEXT', '80'),

    ('1234 ABC', 'TEXT2', '20'),

    ('1234 XYZ',...

    "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 retrieve numbers from a string

    Another way:

    WITH MyCTE(val) AS

    (

    SELECT '21-12-ABCD' UNION ALL

    SELECT '23-1-hdf' UNION ALL

    SELECT '19-1345-dsnf'

    )

    SELECT val,

    SUBSTRING(val, 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: Getting more done with OUTPUT

    Excellent article! Well done.

    "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: is it possible to determine the max length of a field in a csv file?

    Jeff Moden (11/9/2016)


    Alan.B (11/9/2016)


    Jeff Moden (11/8/2016)


    Alan.B (11/8/2016)


    You can accomplish this using NGrams2B which can be downloaded from here[/url] at the end of the article.).

    I must be tired and I'm...

    "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: is it possible to determine the max length of a field in a csv file?

    Jeff Moden (11/8/2016)


    Alan.B (11/8/2016)


    You can accomplish this using NGrams2B which can be downloaded from here[/url] at the end of the article.).

    I must be tired and I'm not seeing what...

    "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: Good books/resources on intermediate T-SQL

    pietlinden (11/8/2016)


    Thanks, Alan... is there a book on T-SQL that discusses using Temp tables etc vs TVFs etc? and CROSS/OUTER APPLY too? (although I like SQLKiwi's explanation of 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

  • RE: Good books/resources on intermediate T-SQL

    Itzik's SQL Server 2012 Window Function book is the best SQL Books I own. His SQL Server 2012 book may be the second best.

    Any article by Jeff Moden, Dwain Camps,...

    "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 foundation funds to settle lawsuits involving

    spam reported.

    "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: ethnic Arab militias has been gaining ground

    Spammers not gaining ground. Spam reported.

    "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: is it possible to determine the max length of a field in a csv file?

    You can accomplish this using NGrams2B which can be downloaded from here[/url] at the end of the article.). I don't know how you are bringing in your CSV file data...

    "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 to implement left join using look up

    My experience has been that this is faster and easier using plain ol' T-SQL. Why not just create a script task and use the query that you queries that 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 a SQL "least significant digit" algorithm

    Phil's solution is brilliant (this was a tricky problem that I could not solve).

    Based on what you said - 4.0 should be 4.1 but if you want 4.0 to...

    "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 use a CSV as parameter in a query

    If you can't add a new UDF you can just apply the logic to a SQL query like so:

    DECLARE

    @pString VARCHAR(8000) = '11,15,200',

    @pDelimiter CHAR(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: How to use a CSV as parameter in a query

    (expanding on what Phil said...)

    You need a "splitter" function - the one Phil posted a link to is the best one for the job. This query:

    DECLARE @param varchar(1000) = '1,2';

    SELECT...

    "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 - 361 through 375 (of 2,458 total)