Forum Replies Created

Viewing 15 posts - 1,126 through 1,140 (of 1,228 total)

  • RE: Calculating interest query

    Paul White (2/27/2010)


    Chris,

    Turns out all that is needed to get rid of the index spool is to define the clustered index as UNIQUE. Given that information, a better plan...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Calculating interest query

    Paul White (2/27/2010)


    It is certainly orders of magnitude faster than a recursive CTE on large sets

    Hi Paul, an excellent solution as always, and a method to remember.

    There are a...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Calculating interest query

    Jeff Moden (2/26/2010)


    nathan 7372 (2/26/2010)


    Thank you for pointing out proper posting etiquette. I had not seen that article before and I apologize.

    Absolutely no problem and no need to apologize....


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Calculating interest query

    Hi Nathan

    Thanks for posting the sample data and expected results, it doesn't half make a difference. Top work.

    Here you go.

    ;WITH CTEdata AS (

    SELECT ExecSeq = ROW_NUMBER() OVER (ORDER BY Dates.[year],...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Fast random row selector

    Have you tried joining to a table containing "random" ID's?

    DROP TABLE #Sampler

    DECLARE @TableSize INT, @SampleSize INT

    SET @TableSize = 1200000

    SET @SampleSize = @TableSize/10 -- 10%

    SELECT TOP(@SampleSize) SampleID = ABS(CHECKSUM(NEWID()))%@TableSize

    INTO #Sampler

    FROM...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Query + XML Data + Time Consuming

    About 450ms on this lappy.

    Cheers

    ChrisM

    Junior Software Engineer


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Simple Date Function Help PLEASE

    @pam:

    sys.databases.[name]


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Simple Date Function Help PLEASE

    DECLARE @startdate DATETIME, @enddate DATETIME

    DECLARE @sql NVARCHAR(MAX)

    SELECT @sql = ISNULL(@sql, '') + 'USE ' + 'name' + '

    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

    select @startdate = dateadd(mm,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))

    select @enddate...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Distinct Counts and Groups By Shift

    Have you eyeballed the data? Try this:

    SELECT

    [Day] = DateName(weekday, LDate),

    LID,

    Shift1 = CASE WHEN LTime < '16:00' THEN 1 ELSE 0 END,

    Shift2 = CASE WHEN...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: help with join predicates in FROM clause

    Steve Barlow-144765 (2/23/2010)


    Hi,

    My client has a piece if SQL he is having trouble with. Here is the SQL:

    He wants to return the results of these joins returned as well as...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: better way to rewrite this code

    klineandking (2/22/2010)


    good afternoon guys am trying to find a better way to rewrite this code, i inherited it from some one else, any help would be welcome

    declare @data_refresh datetime

    set @data_refresh=convert(datetime,convert(varchar(10),getdate(),101))

    select...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Fast random row selector

    Surely...ORDER BY NEWID()

    would be faster than

    WHERE 0.01 >= CAST(CHECKSUM(NEWID(), k.ID) & 0x7fffffff AS float) / CAST (0x7fffffff AS int)


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Value not recognized although data is present

    Hi

    Firstly, try NULLIF instead of ISNULL to eliminate empty strings and NULLs of ErrorDescription from the output.

    Secondly, rewrite the query to eliminate the possibility of more than one row returning...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Humor

    Ray K (2/22/2010)


    I have it taped up on my desk now! 😀

    There's something of the night about you, sir.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Quering data from same table

    Paul White (2/21/2010)


    That's nice code Chris. It represents a nice compromise between the benefits of an indexed view, and the drawbacks related to the maintenance of aggregates for that...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

Viewing 15 posts - 1,126 through 1,140 (of 1,228 total)