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 |
|
Steve2106
Posting Yak Master
183 Posts |
Posted - 2009-09-24 : 16:58:21
|
| Hi There,Can someone point me in the right direction.I need to know how I can loop through one table and insert into another.First Table:AutoId, NameSecond Table:AutoId, FirstTableAutoId,CodeCode field above will be the same for all records.Hope that makes sense. Thanks for your help.Best RgardsSteve |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2009-09-24 : 20:00:27
|
| Expanding on Tara's response, it would be something along the lines of...INSERT INTO Table2 (FirstTableAutoID, Code)SELECT AutoID, 'CodeConstantValue' FROM Table1--------------------------------------------Brand yourself at EmeraldCityDomains.com |
 |
|
|
Steve2106
Posting Yak Master
183 Posts |
Posted - 2009-09-25 : 03:16:17
|
That's perfect.Thanks for taking the time to give the code, I appreciate it.Best Regards,quote: Originally posted by AjarnMark Expanding on Tara's response, it would be something along the lines of...INSERT INTO Table2 (FirstTableAutoID, Code)SELECT AutoID, 'CodeConstantValue' FROM Table1--------------------------------------------Brand yourself at EmeraldCityDomains.com
Steve |
 |
|
|
|
|
|
|
|