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 |
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2011-05-10 : 18:51:04
|
| Hi I have table containing 1 million records with a trans_date column.I want to insert those records In a new table on weekly basis instead of inserting them at once there by blowing up the transaction log. p Lease let me know how i can do it? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-05-10 : 20:12:21
|
i assumed trans_date will correspond to the date the record is created ?insert into new_table ( <column list> )select <column list>from old_tablewhere trans_date > dateadd(datediff(day, 0, getdate()), -7) -- last 7 days KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2011-05-11 : 10:31:53
|
| hi khtan tanks for your reply. But the way i want is first insert a weeks data of jan 2008 into new table then another week so on...til now 2011.The old table contains data since 2008. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-05-11 : 10:42:23
|
just change the @start_date and @end_date to your requirement each time you run the querywhere trans_date >= @start_dateand trans_date < @end_date KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2011-05-11 : 10:54:40
|
| Cant this be put in a while or do while loop? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-05-11 : 12:12:09
|
quote: Originally posted by akpaga Cant this be put in a while or do while loop?
sure. why not. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2011-05-11 : 12:16:55
|
| thank you |
 |
|
|
|
|
|