devxlogo

Quickly copy records between tables with same structure

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 tableDELETE 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.

See also  5 Strategies for Supercharging Your CRM
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist