Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2004-07-08 : 09:49:21
|
| hello,how can I do multiple inserts in an sp ?eg, I am trying to insert name and age of 20 people into one table. staff |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-07-08 : 09:59:28
|
| Insert into staff values(@Name1, @Age1)Insert into staff values(@Name2, @Age2)etc.....Duane. |
 |
|
|
drymchaser
Aged Yak Warrior
552 Posts |
Posted - 2004-07-08 : 10:00:13
|
| Yes you can.Series of INSERT...VALUES (probabaly need a loop here) or if you can get them in a set INSERT...SELECT |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2004-07-08 : 11:04:10
|
| INSERT INTO MyTable (Name, Age)SELECT 'Sam', 18UNION ALLSELECT 'Brett', 24UNION ALLSELECT 'Tara', 16et cetera |
 |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-07-09 : 02:46:33
|
| You are being very kind to the other community members SamDuane. |
 |
|
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
Posted - 2004-07-09 : 02:52:24
|
| If u r sending the multiple values thru the front end, then it is better to send an xml to the store procedure rather than calling the sp in a cursor. This will save lot of round trips. Use openxml method to read the xml. Check BOL for the same.regardsSachin |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-07-09 : 08:25:56
|
quote: Originally posted by ditch You are being very kind to the other community members Sam
I think its a bit of old code out of Archive ...Kristen |
 |
|
|
|
|
|