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 |
|
sfjtraps
Yak Posting Veteran
65 Posts |
Posted - 2009-09-17 : 11:21:08
|
| Can someone explain how to INSERT multiple records, incrementing a field in the record. (Like doing a for next next type loop in VB)For instance, if I want to INSERT the following data record 10 times and increment x from 1 to 10 each time a record is inserted. x being the first column.x,2ndColumn,3rdColumn,4thColumn |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-17 : 11:26:12
|
You can do that with selectrow_number() over (order by (select 1)) as x,2ndCol,...from ...orwhile begin endorinsert tableselect 1, 2ndCol,... union allselect 2, 2ndCol,... union allselect 3, 2ndCol,... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|