find duplicates
SELECT column,COUNT(*) c FROM table GROUP BY column HAVING COUNT(*) > 1
results show the column value and the number of duplicates for that value
TextSnippets > tsql >
Post code snippets. Sort by tags, people, people and tags, etc..
| « Earlier | 3 items total | Later » |
SELECT column,COUNT(*) c FROM table GROUP BY column HAVING COUNT(*) > 1
DECLARE @order int
SET @order = 1
SELECT * FROM users
ORDER BY
CASE WHEN @order = 1 THEN [name] END DESC,
CASE WHEN @order = 2 THEN [name] END ASC,
CASE WHEN @order = 3 THEN [email] END DESC,
CASE WHEN @order = 4 THEN [email] END ASC
SELECT TOP 10 userID FROM user ORDER BY NEWID()
SELECT TOP 10
NEWID() [egg],
userID
FROM user
ORDER BY [egg]
SELECT TOP 10
NEWID(),
userID
FROM user
ORDER BY 1
| « Earlier | 3 items total | Later » |