MS SQL Delete duplicate records

Source: Internet
Author: User
Repeat: I built a table in MS SQL, but for a variety of reasons some records are duplicated
: The record is exactly the same.
: Now I want to delete the duplicates, just keep the first one in the duplicate record.
: I seem to have seen a presentation of Oracle in the database,


SELECT DISTINCT * INTO #table_name table_name
Delete from table_name
SELECT * INTO table_name from #table_name
drop table #table_name

Related to this is the "SELECT INTO" option, which can be used in database properties
dialog box, either hook up this item, or execute in Query Analyzer
Execute sp_dboption ' db_name ', ' SELECT INTO ', ' true '
Open. The default value is off.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.