SQL SERVER: Delete Duplicate Rows with Primary Id
(This is MS-SQL specific)
DELETE FROM TableName WHERE Id NOT IN (SELECT MAX(Id) FROM TableName GROUP BY DuplicateColumName1, DuplicateColumName2)
11304 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
DELETE FROM TableName WHERE Id NOT IN (SELECT MAX(Id) FROM TableName GROUP BY DuplicateColumName1, DuplicateColumName2)
declare @search varchar(50) SET @search = 'searchterm' SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE @search ORDER BY ROUTINE_NAME
select * from OpenDataSource(’SQLOLEDB‘,’Data Source=server.asdf.com;User ID=yourusername;Password=yourpassword‘).somedatabase.dbo.sometable;