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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying A Table 1

Status
Not open for further replies.

chendes

Technical User
Dec 4, 2003
12
0
0
GB
Using SQL what is the quickest way of copying a table
 
If you mean you want to duplicate a table and its contents, try

select *
into newtable
from table

then you need some VBA code to set up primary and foreign keys and referential integrity.

John
 
Thats fantastic. Is it possible to do a select into an exsisting table as apposed to create a new table?
 
Yes:

Insert Into Tablename (Field1, Field2, Field3)
Select Field4, Field5, Field6 From Oldtablename

Remember that the primary key restrictions will be enforced, and you can restrict the records that can be copied using a Where clause on the select.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top