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 !




How to Copy only Unique Records from one Table to Another Table


Posted Date: 20 May 2008    Resource Type: Code Snippets    Category: SQL
Author: shalini jenniferMember Level: Gold    
Rating: Points: 10



The following code sample shows how to Copy only Unique Records from one Table to Another Table.


select * into newtablename from oldtablename where 1>2

It Copies only the structure of the oldtable to the new table


insert into newtablename select distinct * from oldtablename


It Copies only the Unique Records from one oldtablename to a newtablename

The new table generated has only distinct values of the oldtable ie unique values only




Responses

Author: Kapil Dhawan    17 Jun 2008Member Level: Gold   Points : 2
Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code will help lots of guys
Thanks to you
Regards,
Kapil



Author: Bunty    01 Jul 2008Member Level: Diamond   Points : 2
Hi,

Very nice piece of code.

Short and simple to understand.

Thanks for sharing your knowledge with us.

Keep posting.

Thanks and Regards
S.S.Bajoria


Author: Payal Jain    01 Jul 2008Member Level: Gold   Points : 2
u can also use it like this:

select * into newtablename from (select distinct * from oldtablename)x

it performs both the jobs with 1 single query


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Unique Records  .  

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: What is the STUFF Function ?
Previous Resource: To See The Indexes in a Particular Table
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use