Forum Replies Created

Viewing 15 posts - 1,141 through 1,155 (of 2,462 total)

  • RE: Function to find and replace from a string where like or contains

    Sean Lange (12/3/2015)


    Alan.B (12/3/2015)

    I am curious about a couple things here.

    Why MAX(c)?

    (MAX(c),'No Colour')

    I usually do that to get a single value but don't have a clue why I did that....

    "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: Function to find and replace from a string where like or contains

    First, I don't know if you noticed or understood the motivation by Luis' comment in his code about why he changed it to varchar(8000) from varchar(max). You only want 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: Selecting the top row from a group of records.

    It is worth noting that you will need an ORDER BY in your OVER clause for this to 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: writing queries that easily readable

    I terminate all my SQL statements with a semicolon because, apparently, you are supposed to. If anyone is interested in an intellectually stimulating article on the subject see Itzik Ben-Gan's...

    "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: Generate sequence of numbers between values

    First, below is a simple and easy solution that is much less complicated than a loop-based, multi-variable solution. It also performs quite well (for when performance does matter).

    DECLARE @rng-2...

    "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: Rethinking Hiring

    I think there are three problems:

    1. The genuine need for talented data pros is growing much faster than the supply of talented data pros.

    2. Many (perhaps most) companies...

    "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 the posted questions getting worse?

    Brandie Tarvin (11/30/2015)


    Luis Cazares (11/30/2015)


    Brandie Tarvin (11/30/2015)


    Eirikur Eiriksson (11/27/2015)


    Brandie Tarvin (11/27/2015)


    My SO just informed me that he's learned how to write a LEFT INNER JOIN in Oracle.

    And now my head...

    "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: Identifying Rock/Paper/Scissors Scenarios

    jmpatchak (11/21/2015)


    My apologies. H/T to Alan for the script to set up the DDL:

    /****************************************************************************************

    (1) Setup DDL

    ****************************************************************************************/

    IF OBJECT_ID('dbo.Chooser') IS NOT NULL DROP TABLE dbo.Chooser;

    IF OBJECT_ID('dbo.Book') ...

    "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: Alternative Way to Parse JSON String?

    omegadev21 (11/20/2015)


    Jeff Moden (11/20/2015)


    Ah... maybe I missed it. Is this the data example?

    Given the field CLIENT_DATA of data type VARCHAR(MAX) with data:

    {"LASTNAME":"Doe","FIRSTNAME":"John","EMAILADDRESS":"something@email.com","USERNAME":"exusername","PHONENUMBER":"15555555555"}

    @jeff Moden, yeah that's the sample...

    If only 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: Identifying Rock/Paper/Scissors Scenarios

    This seems like a fun little exercise and this kind of thing sharpens your skills for sure. +1000.

    Here's what I put together. Note that I cleaned up your DDL....

    "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/Instance List

    There's a bunch of ways to do this using T-SQL, a CLR, Powershell, cmdexec, etc. You should copy an attachment of what the text file looks like (you don't need...

    "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: Pieces of SQL code stored in table

    I wonder how popular this kind of solution is...

    Did anybody come across something similar?

    I'm currently on a project migrating an Oracle-based data warehouse / Cognos Reporting solution over 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: Alternative Way to Parse JSON String?

    A purely T-SQL solution:

    Consuming JSON Strings in SQL Server[/url] by Phil Factor

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

    Jacob Wilkins (11/20/2015)


    Perhaps something like this?

    CREATE TABLE Query_Test

    (

    CPU INT ,

    ApplicationName VARCHAR(100) ,

    ...

    "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: Query MSDB for SSIS packages connection managers

    This should do the trick. I just cooked this up and only had like 10 SSIS pacakages available to test against so there is likely more stuff you can extract....

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