[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 467
  • Last Modified:

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.


 
0
mleidich
Asked:
mleidich
1 Solution
 
Anil GolamariCommented:
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.
0
 
mleidichAuthor Commented:
No TEST01 is not created yet.  I need it to be an exact copy of TEST.
How would I do this?
0
 
Anthony PerkinsCommented:
>>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
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
mleidichAuthor Commented:
where do you type SELECT * INTO?

Will DELETE TEST  - delete the table?

Will TRUNCATE erase all data in the table?
0
 
Ramkisan JagtapLead DeveloperCommented:
select * into test01 from test
0
 
mleidichAuthor Commented:
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.
0
 
Anthony PerkinsCommented:
You will click on New Query on the top left corner below the File menu and then type in the query I posted.

Read up on DELETE and TRUNCATE TABLE in SQL Server BOL.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now