Forum Replies Created

Viewing 15 posts - 1 through 15 (of 920 total)

  • RE: Request help with a query

    Bob Hovious (9/15/2009)


    where there may be many factors beyond one's control

    This is exactly why you DON'T want screen display time in the mix. It includes system processes that...

  • RE: practical RBAR removal: convert integers to binary

    Here's my "piecemeal" solution that works with any positive integer:

    DECLARE @IntVal int;

    SET @IntVal = 2147483647;

    SELECT @IntVal / POWER(2,16), @IntVal % POWER(2,16);

    SELECT

    REPLACE(STR(ISNULL((SELECT SUM(POWER(CAST(10 AS bigint),h.number))

    FROM master.dbo.spt_values h

    WHERE h.type = 'P' AND...

  • RE: Request help with a query

    Bob Hovious (9/15/2009)


    Okay.... I knocked this out before taking off for lunch. Now anybody reading can satisfy themselves using Jonathan's measurement of time to execute, since he doesn't seem...

  • RE: Sliding data to the left

    I'm confused by your code snippets, but I think I understand your text.

    If you want the result set to have multiple columns that you will subsequently concatenate, you could use...

  • RE: Request help with a query

    Bob Hovious (9/15/2009)


    And I'll take a helicopter over your hunter.

    Next you get a sparrow missile to shoot down my helicopter....

    Does this mean you've found a method that's faster than the...

  • RE: practical RBAR removal: convert integers to binary

    SQLBOT (9/15/2009)


    Jonathan,

    Brilliant! Thanks.

    I like the power and bitmask method of conversion.

    That beats the modulus and division method (I think).

    I should have specified that I wanted to use a tally...

  • RE: Request help with a query

    Bob Hovious (9/15/2009)


    2) It works with versions of SQL Server older than SQL Server 2005.

    True, and I used to code that way before better techniques were made available in...

  • RE: Request help with a query

    Bob Hovious (9/15/2009)


    I do not know why such a long query has been posted.

    ;with cte as (select *,ROW_NUMBER() over(partition by vehicle order by dueHours) as seqID from @sample...

  • RE: Request help with a query

    Dave Ballantyne (9/15/2009)


    This is the output i get from set statistics io on .

    Non Cte

    Table 'SalesOrderDetail'. Scan count 31466, logical reads 103081, physical reads 0, read-ahead reads 0, lob logical...

  • RE: practical RBAR removal: convert integers to binary

    If you're fixed on using a "tally table," I guess you could try something like this:

    DECLARE @IntVal int;

    SET @intVal = 54321;

    SELECT SUM(POWER(CAST(10 AS bigint),v.number))

    FROM master.dbo.spt_values v

    WHERE v.type = 'P' AND...

  • RE: Group by Count question

    And here's the reminder about that keyword from SQL Server 2008 BOL:

    ALL

    This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in...

  • RE: Request help with a query

    HowardW (9/15/2009)


    The thing is I suspect it would be slower with a large dataset. If you want to preserve both rows in the event of a tie, use rank() rather...

  • RE: Querying on field with multi-values

    If you have control over the schema design, please take Bob's advice. And read up on database normalization.

  • RE: Request help with a query

    Bob Hovious (9/14/2009)


    We forgive you for agreeing with us, PP 🙂

    I'm afraid I cannot agree. I'd still use something like this:

    SELECT ID, Vehicle, DueHours, DueName

    FROM @sample s

    WHERE DueHours IN

    (SELECT...

  • RE: T-SQL Join Help

    SELECT ID, Dep, [Key]

    FROM #Temp t

    WHERE [Key] = 0 AND NOT EXISTS

    (SELECT *

    FROM #Temp

    WHERE [Key] t.[Key] AND Dep = t.Dep)

Viewing 15 posts - 1 through 15 (of 920 total)