SQL statement to remove duplicate records, get duplicate records _mssql
Source: Internet
Author: User
SQL statements remove duplicate records, get duplicate records
--Query a table to effectively remove duplicate records, UserID as a self-growing primary key, Roleid as a repeating field
SELECT MIN (UserID) as UserID, Roleid from Tmptable GROUP by Roleid
SELECT Roleid from Tmptable GROUP by Roleid (COUNT (*) > 1)
SELECT DISTINCT * from tmptable
SQL statement query for all table names in SQL Server Access database, field name February 01, 2007 Thursday PM 04:21sql Server
View all table names:
Select name from sysobjects where type= ' U '
Query table for all field names:
Select name from syscolumns Where id=object_id (' Table name ')
SELECT * FROM Information_schema.tables
SELECT * FROM Information_schema.views
SELECT * FROM Information_schema.columns
ACCESS
View all table names:
Select name from Msysobjects where type=1 and flags=0
The msysobjects is a system object, and the default is hidden. Make it visible through tools, options, views, displays, and system objects
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.