Why INSER INTO ... UNION ALL?

  • Mohit (3/10/2009)


    And most of my developer buddies hate UNION ALL because they find it it makes it hard to read.

    I never understand that part, I know some of it is just personal preference, but if you understand what it does, why would it be harder to read? It's like going to Canada from the US and saying the speed limit is 'harder to read' because you're not used to KPH. Does the same thing, just a different way of doing it.

    side note - everytime I do the above, and see those 'seatbelts compulsory' signs, I feel like an uneducated hick. I'm used to 'Buckle Up'

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."

  • Heh his been IT for 20+ years 😛 SO I call him old-timer LOL .. his just stuck in his ways :). We good buddies he actually listens; but really hard to change him because his used to doing it his way ...

    Mohit.

    [font="Arial"]---

    Mohit K. Gupta, MCITP: Database Administrator (2005), My Blog, Twitter: @SQLCAN[/url].
    Microsoft FTE - SQL Server PFE

    * Some time its the search that counts, not the finding...
    * I didn't think so, but if I was wrong, I was wrong. I'd rather do something, and make a mistake than be frightened and be doing nothing. :smooooth:[/font]

    How to ask for help .. Read Best Practices here[/url].

  • To be honest, I am rarely trying to do this for over 10-20 rows (just to type up sample data). At that volume, it really doesn't matter.

    Once 2008 takes hold everywhere, I will probably switch over to the row constructor format.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • That's SQL Server 2008 🙂

    Florian Reischl (3/10/2009)


    Hello Bruce

    Thank you for your answer! In my opinion it "because" a absolutely valid reason :).

    I just found a third possibility in MSDN forums http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/8d2888ab-9ad6-47f2-a01c-0a487b1dc995/ which I never saw. Example:

    DECLARE @t TABLE (id INT, txt VARCHAR(100))

    INSERT INTO @t VALUES

    (1, 'hello'),

    (2, 'world')

    SELECT * FROM @t

    I do not have a specific business case at the moment I just would like to understand why other DBAs/developer do how they do and if there may be any advantage for my work.

    Greets

    Flo

Viewing 4 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply