Forum Replies Created

Viewing 15 posts - 16 through 30 (of 98 total)

  • RE: Sorting Months By Number (SQL Spackle)

    How about this way:

    SELECT [Month] = datename(mm,min(SomeDateTime)),

    Amount = SUM(SomeAmount)

    FROM #MyHead

    WHERE SomeDateTime >= '2010' AND SomeDateTime...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: A simple trick for “Block Comment” syntax in SSMS

    How about the comment toggle trick:

    -- Toggle trick

    SELECT 'Toggle line 1'/*

    SELECT 'Toggle line 2'--*/

    By commenting line 1 line 2 becomes active.

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: Transactional Replication without snapshot replication (SQL Server 2005)?

    It's the Database!!! (5/16/2013)


    Thanks however this was 3 years and 2 companys ago! 😀

    :w00t:

    I wasn't paying attention to the date of your post but to the more recent ones. I...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: Transactional Replication without snapshot replication (SQL Server 2005)?

    It's the Database!!! (6/29/2009)


    Does anybody know how to replicate a DB from 2005 to 2008? It will not let me add 2008 as a subscriber? any ideas?

    It is about the...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: A Hazard of Using the SQL Merge Statement

    Phil Parkin (4/3/2013)


    It is good to use subset of the source table, considering that you don't need the whole table content.

    I don't understand what you mean - please elucidate.

    What...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: A Hazard of Using the SQL Merge Statement

    vliet (4/3/2013)


    We tried both the CTE approach and the AND clause on the WHEN NOT MATCHED BY SOURCE part to merge rows spanning only a certain period. The performance of...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: A Hazard of Using the SQL Merge Statement

    If the bound errors happens than you will have to replace it with an EXISTS condition:

    ... and exists (select * from #test2 where id =t.id)

    The author was kind of superficial...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: A Hazard of Using the SQL Merge Statement

    al_kessler (4/3/2013)


    P Jones (4/3/2013)


    As another MERGE fan I'd use

    WHEN NOT MATCHED BY SOURCE AND (t.ID = s.ID) THEN DELETE;

    in the original merge statement.

    But I've no complaints about the...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    Did I miss something? I didn't have the patience to go over all 54 pages of replies. Initially when the code for the cteTally was changed to be faster it...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: Divide by zero

    The "official" answer given is not accurate. Views 3 and 6 are not created due to syntax errors and from the rest 1, 4 and 5 don't return errors if...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: Get month names ordered using recursion

    --===== 2005 Method, 100,000 rows ====================================================================================

    DECLARE @SomeNumber INT;

    SELECT @SomeNumber = 100000 ;

    WITH

    E1(N) AS (SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: Get month names ordered using recursion

    Jeff Moden (3/24/2012)


    the sqlist (3/24/2012)


    ChrisM@home (3/24/2012)


    the sqlist (3/24/2012)


    ...I think we should not be worried about how many rows are actually generated...

    I couldn't disagree more. When you're looking at an overall...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: Get month names ordered using recursion

    ChrisM@home (3/24/2012)


    the sqlist (3/24/2012)


    ...I think we should not be worried about how many rows are actually generated...

    I couldn't disagree more. When you're looking at an overall time of 25ms per...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: Get month names ordered using recursion

    And here is for 100,000 and 1,000,000 numbers:

    set statistics time on

    set statistics io on

    SELECT n = (n1 + n2 + n3 + n4 +n5)

    FROM (((VALUES (0),(100),(200),(300),(400),(500),(600),(700),(800),(900)) t3 (n3)

    CROSS JOIN...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

  • RE: Get month names ordered using recursion

    Practically there is no difference in terms of load:

    set statistics time on

    set statistics io on

    SELECT n = (n1 + n2 + n3 + n4)

    FROM (((VALUES (0),(100),(200),(300),(400),(500),(600),(700),(800),(900)) t3 (n3)

    CROSS JOIN...

    Don't just give the hungry man a fish, teach him how to catch it as well.

    the sqlist

Viewing 15 posts - 16 through 30 (of 98 total)