Forum Replies Created

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

  • RE: How to use a year and month fields to get a range of records

    pietlinden (4/28/2015)


    Save yourself the headache. Store the dates as dates, not as two columns with numbers. Then you can do date math really easily, index columns and all...

    "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 year and month fields to get a range of records

    I think you are looking for (I'm calling your Year column "yearCol" and month column "monthCol":

    WHERE

    (yearCol = 2014 AND monthCol >= 9) -- All dates in year...

    "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: Matching two Data Sets

    Using the DDL and example data that you provided can you provide an example of what the correct output would look like?

    "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 worth to pursue a C# cert for a SQL Dev focused career path?

    Getting a cert should not hurt you in any way. That said, I learned C# about 12/13 years ago because, at the time I wanted to be a .NET web...

    "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: XML Data retrieval

    The @ sign is used for referring to XML attributes. You are looking for the value of the Element.

    Below is the code that will get you what you are...

    "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 is a "set-based loop?"

    dwain.c (4/27/2015)


    Alan.B (4/27/2015)


    Jeff Moden (4/26/2015)


    Alan.B (4/26/2015)


    Over the past year I have heard some folks around here talk about a "set based loop". What's that all about? Can someone provide an...

    "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 is a "set-based loop?"

    Gary Harding (4/27/2015)


    Jeff Moden (4/26/2015)


    You're seriously aware of one of the more famous Pseudo-Cursors there is... a SELECT that uses a Tally Table.

    When I first saw this type of usage...

    "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 is a "set-based loop?"

    Jeff Moden (4/26/2015)


    Alan.B (4/26/2015)


    Over the past year I have heard some folks around here talk about a "set based loop". What's that all about? Can someone provide an example?

    There are...

    "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: Noob Powershell String Parsing Question

    I figured it out...

    $myArray =@()

    foreach ($item in $TestLocations) { $myArray += $item.LineNumber }

    "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: Compare column in two tables

    dwain.c (4/20/2015)


    Interesting solutions there gentleman, but regardless of how you set up your PRIMARY KEY/INDEXing, might this not be just a tad simpler?

    SELECT name, =MAX()

    FROM

    (

    SELECT name,...

    "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: Compare column in two tables

    DonlSimpson (4/22/2015)


    Alan.B (4/21/2015)


    Minnu (4/21/2015)


    Hi Team,

    The solution provided by are working fine..

    but there is a change in my result.

    my request is

    if a record_1 is in Table_A and Table_B, then

    output...

    "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: ? on parsing XML field

    Read Paul Whites articles about APPLY, they are the best out there IMHO. These are the two article that really helped me understand APPLY:

    Understanding and Using APPLY (Part 1)[/url]

    Understanding 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: ? on parsing XML field

    -- a db we both have

    USE tempdb

    GO

    -- create your table

    IF OBJECT_ID('tempdb.dbo.xdocuments') IS NOT NULL DROP TABLE dbo.xdocuments

    GO

    CREATE TABLE dbo.xdocuments(xid int not null, yourxmlcolumn xml not null);

    GO

    -- insert a couple records

    INSERT...

    "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: Transpose Rows to columns

    Luis and Sean beat me to it... I was going to add, here's a good article on this subject:

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns[/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: Need To Improve View Performance

    J Livingston SQL (4/22/2015)


    Alan.B (4/22/2015)


    This is what I came up with:

    SELECT

    ab.AddressCode,

    AddressInstance = ROW_NUMBER() OVER (Partition by ab.AddressCode ORDER BY (SELECT (NULL))),

    ab.PostCode,

    ...

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