Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

How to insert multiple rows into a table with identity column Expand / Collapse
Author
Message
Posted Thursday, January 12, 2012 7:22 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 4:34 AM
Points: 1,622, Visits: 1,409
Ha, ha, ha! "...warm and cuddly...". I like that.

I was going to say "rude", but I choose the word "abrasive" instead.

I am all for learning, and for helping others learn for themselves, as opposed to just providing answers, which is what a lot of the posters here want, but there's no need for insults. Like you, I feel that it would do more harm than good.

But, hey...to each his own, right?!
Post #1234801
Posted Friday, January 13, 2012 8:41 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 8:48 AM
Points: 1,184, Visits: 2,679
GilaMonster (1/12/2012)

... Personally I think it just drives them away ...


And it looks he's succeeded! No sign of the OP


--
Nigel
Useful Links:
How to post data/code on a forum to get the best help
The "Numbers" or "Tally" Table - Jeff Moden

Post #1235703
Posted Friday, January 13, 2012 9:17 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 6:55 AM
Points: 9,928, Visits: 11,203
nigel. (1/13/2012)
And it looks he's succeeded! No sign of the OP

The simple question was answered long before Joe posted. It seems the questioner has his or her answer, but just hasn't returned to say so.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1236074
Posted Friday, January 13, 2012 9:22 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 2:42 PM
Points: 35,768, Visits: 32,431
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1236075
Posted Friday, January 13, 2012 9:31 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 6:55 AM
Points: 9,928, Visits: 11,203
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.

This confuses logical design with physical implementation. Certainly, meaningless numeric 'tuple identifiers' are of little use in a purely relational logical design, and many would consider their use to violate some normal form or another. That's irrelevant when we come to implement the logical design though: physical identifiers are frequently an important physical optimization. Also, SQL Server is not a pure relational RDBMS, and nor is SQL a set-orientated language: it has bag semantics, not set semantics.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1236077
Posted Tuesday, September 3, 2013 3:50 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, September 3, 2013 3:48 AM
Points: 1, Visits: 0
Solution:

1) Set IDENTITY_INSERT to ON.

2) Insert customers data into Customer table.

3) Set IDENTITY_INSERT to OFF.

Read full article here.
Post #1490852
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse