Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically backup table

Status
Not open for further replies.

Hackster

Programmer
Mar 28, 2001
173
US
Primarily I use Oracle, but for this particular project, I'm using SQL Server. When I want to copy an Oracle table through code, I say
Code:
create table tablename_bak 
as select * from tablename;
But, SQL Server gives me a syntax error. How do you do this in SQL Server language?
 
SELECT * INTO MyNewTable FROM MyOldTable

"I'm living so far beyond my income that we may almost be said to be living apart
 
no problem

"I'm living so far beyond my income that we may almost be said to be living apart
 
Can I use SELECT * INTO MyNewTable FROM MyOldTable to backup data from one table into the backup table up to a certain point in time? And, how can I delete the records from the actual table (since I have the data backed up in the backup table I don't need it in the actual table, right?)

Thanks.


____________________________________
Just Imagine.
 
couldn't you do this

"SELECT * INTO MyNewTable FROM MyOldTable; Delete * from MyOldTable
 
I guess I can do that.

Do you see any downside to something like this? I described my situation here thread183-1032378

And would this be legal:
Code:
SELECT * INTO answers_backup
FROM answers
WHERE createdate <= '1/31/2004 23:59:59'

DELETE *
FROM answers
WHERE createdate <= '1/31/2004 23:59:59'


____________________________________
Just Imagine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top