I am new to SQL. and this was in place when I started here.
I have a sql2000 database. It is opened with SQL Server manager 2005.
I have a table that needs to be archived every so often. The table is called TEST.
I need to copy the entire table ( data and columns) to a table called TEST01. Then need to erase all data in TEST so it is empty.
Should I rename TEST to TEST01 then copy the table structure to a new table call TEST?
How can I do this and what commands would it be.
Microsoft SQL ServerMicrosoft SQL Server 2005
Last Comment
Anthony Perkins
8/22/2022 - Mon
Anil Golamari
If you have Test01 table already created then easy way to copy the data from Test table to Test01 table is creating a DTS package if you don't have SSIS package available. In this way you can schedule this package to run and at the same time one's you copy the whole content to Test01 table you can delete the data from Test table.
mleidich
ASKER
No TEST01 is not created yet. I need it to be an exact copy of TEST.
How would I do this?
Anthony Perkins
>>I need to copy the entire table ( data and columns) to a table called TEST01. <<
SELECT * INTO TEST01 FROM TEST
>>Then need to erase all data in TEST so it is empty.<<
If no Foreign keys: TRUNCATE TABLE TEST
Else: DELETE TEST