Home Forums SQL Server 2008 T-SQL (SS2K8) How to insert multiple rows into a table with identity column RE: How to insert multiple rows into a table with identity column

  • CELKO (1/5/2012)


    This is only one reason why good SQL programmers never use this proprietary non-relational "feature" in their code.

    Back to foundation. SQL is a set-oriented language. When you do an INSERT you put in a set, all at once. That set can be zero or more rows.

    But IDENTITY is a sequential count of insertion attempts. PHYSICAL insertion attempts. Not a LOGICAL concept at all. So how do you number these rows?

    Please read a book on RDBMS; your mindset is still in magnetic tape files and not RDBMS yet.

    Actually, good programmers use this feature all the time and for good reason. Please see the following video...

    http://technet.microsoft.com/en-us/sqlserver/Video/gg508879

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)