Avatar of mleidich
mleidich
 asked on

Copy Table in SQL2000

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

Avatar of undefined
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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
mleidich

ASKER
where do you type SELECT * INTO?

Will DELETE TEST  - delete the table?

Will TRUNCATE erase all data in the table?
Ramkisan Jagtap

select * into test01 from test
mleidich

ASKER
I see the table names on the left.  I highlight the name of the table.  I do not see how to type or select the command SELECT from TEST.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Anthony Perkins

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.