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 |
|
Dwish1372
Starting Member
7 Posts |
Posted - 2008-01-14 : 22:44:05
|
| hi everyone,I have a couple questions. I'm very new to SQL and I have this problem:I need to be able to drop the contents of Existingtable_B into Newtable_A - I found this command (below) that will make a 'copy' but I don't want to keep the contents of Existingtable_B. Is it possible to drop them into Newtable_A instead of copy? Also, I want to do this for 5 tables on Sundays at midnight.. how could I schedule that? Finally, what happens if there is not enough space or some other critical error happens during this procedure? I don't want to lose the data.Any help is greatly appreciated.select * into Newtable_A from Existingtable_B |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
barny.spencer@openoffice.
Starting Member
3 Posts |
Posted - 2008-01-14 : 22:52:39
|
| Hi Dwish1372.If the structure of the two tables is the same you can do a;INSERT INTO Newtable_ASELECT * FROM Existingtable_Bor specify field names if needed.followed by;DELETE Existingtable_Bto clear all existing data.Wrap the whole lot up in a transaction within your stored procedure to avoid data loss if something nasty happens during processing.To create a schedule you can place these statements in a stored procedure and then create a job to execute it on a schedule.A job can be configured to email/log any errors that occur too.Cheers. |
 |
|
|
|
|
|