C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Quickly copy records between tables with same structure


Posted Date: 09 Mar 2004    Resource Type: Articles    Category: Databases
Author: Satheesh SugumaranMember Level: Gold    
Rating: Points: 10



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.




Responses

Author: Sankaranarayanan.M    26 Jul 2004Member Level: Bronze   Points : 0
the way u proposed is the most effective way. and another way is to just go for
Select * into NEWtbl from OLDtbl.

this is another way of moving records from one table to other with the same structure.But the only disadvantage in this command is it takes time to execute.
Thankz for u .
SankarM


Author: Sankaranarayanan.M    07 Aug 2004Member Level: Bronze   Points : 0
What happens to the execution time.if u insert millions of records into a table which already having millions of records.
Plz anwser me. i'm in great need for it.
Thankz


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Tip on Variable Declaration in SQL 2000
Previous Resource: Swap the values of two columns
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use