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 |
JezEling
Starting Member
4 Posts |
Posted - 2007-07-24 : 09:46:49
|
Hi All,I have a sql statement which is driving me around the twist. I have a table of data made up of individual part numbers which I need to compile and build into a new table. I need to insert the part numbers into a new table once for each week of the year, so each part number will be in the table 52 times, additionally I need to store the week number in the same record. Try as I might I can't figure out which way to achive this, some sort of loop would be the most obvious choice but is not something i've done before in SQL.Any pointers or suggestions would be very much appreciated.CheersJez |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
JezEling
Starting Member
4 Posts |
Posted - 2007-07-24 : 10:19:29
|
Thanks for that and the quick response. However i'm unsure as to how to link this up to create my new table structure, i.e. the same part number entered 52 times for all 1188 part numbers stored in my inital table.Not wishing to sound dumb here, but any other pointers would be much appreciated. |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-24 : 10:22:40
|
[code]insert into yourtable( . . . )select < column list from your_initial_table >from your_initial_table cross join F_TABLE_NUMBER_RANGE(1, 52)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-24 : 11:21:43
|
or if you're doing it from SSMS you can do:Insert into....select ....GO 52_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
|
|