Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: SS7,VB6,VBS
Expertise: beginner
Apr 29, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Quickly copy records between tables with same structure

The SQL language offers a simple and effective way to quickly move all records from a table to another table with same field structure, that is same fields' name, type and position:
INSERT Customers SELECT * FROM New_Customers
-- you can optionally complete the move by
-- deleting all records in the source table
DELETE New_Customers
If the fields have different names, or if the target tables doesn't include all the fields in the source table, you must provide a field list:
INSERT Customers (Name, Address, City, Nation) VALUES 
    SELECT Name, Address, City, Country FROM New_Customers
If fields also have a different type in the two tables, you must convert data on the fly using the CONVERT() function.
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date