Forum Replies Created

Viewing 15 posts - 2,206 through 2,220 (of 2,462 total)

  • RE: Running Total Query

    Glad to help 🙂

    "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 # in first letter of table names?

    HanShi mentioned local and global temp tables. You don't see this as often but a global temp table has two numbers signs in front of it like so: ##temptable.

    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: Running Total Query

    The COALESCE method for running totals is terribly slow. Working with the link that Sean posted, here is an example of how to accomplish this using the "Quirky Update" method....

    "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 needed for Select Query

    Based on the information you provided this may be what you are looking for:

    USE tempdb;

    IF OBJECT_ID('tempdb..Customer') IS NOT NULL

    DROP TABLE Customer;

    IF OBJECT_ID('tempdb..CustomerDetails') IS NOT NULL

    DROP TABLE CustomerDetails;

    IF OBJECT_ID('tempdb..TargetActivity') IS 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: Max of 2 dates

    dwain.c (7/3/2013)


    Gentlemen,

    We are all gentlemen here right? Is it too late to join the party, or skirmish as the case may be?

    How's this one stack up in your test...

    "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 derive avg execuion time for 3 tables

    No problem!

    "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 derive avg execuion time for 3 tables

    I think this will do the trick:

    -- (1) Create table and sample data:

    DECLARE @x TABLE

    (TableName varchar(3) not null,

    BeginTime datetime not null,

    EndTime datetime not null);

    INSERT @x

    SELECT 'T1', '2013-06-02...

    "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: Explanation of LIKE '%[0-9]%'?

    This should be helpful too: MSDN match expression article.

    "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: General Question

    This is an interesting read about an in-house DSS application built by NASA for their Program Managers:

    The NASA Program Management Tool:A New Vision in Business Intelligence.

    "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: Magic Quadrant for Monitoring Software?

    My $0.02...

    The two products I have had the most experience with are Idera SQL Diagnostics Manager and Quest (Foglight & Spotlight).

    I'm personally a huge fan of Idera SQL...

    "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: Date Query Issue

    SQL_FS (6/27/2013)


    What about this?

    SELECT

    SeqNo

    , coalesce(Data.startYear, src.startYear) AS [startYear]

    , coalesce(data.endYear, src.endYear) AS [endYear]

    , coalesce(data.Number, src.Number) AS [Number]

    , src.name

    FROM @tblJobHist_src src

    OUTER APPLY

    (

    SELECT

    min(startYear) AS [startYear]

    , max(endYear) AS [endYear]

    , sum(Number) AS [Number]

    FROM @tblJobHist_src src2

    WHERE

    src2.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: "Running totals" query

    Barkingdog (6/27/2013)


    I had never heard of a "triangular" join but I verified it is incredibly slow. . (I actually took the very data involved, exported it to a CSV...

    "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: Date Query Issue

    Thank you everyone. I figured it out... Not the prettiest solution but it works.

    -- With the numbers

    WITH islands AS

    (SELECT t1.SeqNo, t1.StartYear, t1.EndYear, t1.name

    FROM @tblJobHist_src t1

    JOIN @tblJobHist_src t2...

    "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: Date Query Issue

    Sean Lange (6/26/2013)


    Alan have you looked at islands and gaps. I am pretty sure this is exactly what you need here.

    http://www.sqlservercentral.com/articles/T-SQL/71550/%5B/url%5D

    It is, thanks Sean. I don't have my Ben Gan...

    "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: Max of 2 dates

    Sean Pearce (6/26/2013)


    Alan.B (6/26/2013)


    Sean Pearce (6/26/2013)


    Alan.B (6/25/2013)


    Which is why I included two solutions: My original solution which I believe is correct and one which was cleaner and faster than 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 - 2,206 through 2,220 (of 2,462 total)