Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Quickly copy records between tables with same structure

Total Hit ( 3024)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


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:

Click here to copy the following block
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:

Click here to copy the following block
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


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.