Posts

Showing posts from January, 2013

SQL Query to list all tables with Identity columns

SELECT t . name AS [Table_Name] , c . name AS [Column_Name] , tp . name AS [Data_Type] , c . max_length AS [Size] FROM sys . tables t JOIN sys . columns c ON t . object_id = c . object_id JOIN sys . types tp ON c . system_type_id = tp . system_type_id WHERE c . is_identity = 1 and t . name not like 't_%' order by t . name

How to Delete Duplicates from a table with no Identity Column

with duplicate as ( SELECT      row1 , row2 , row3 , row_Number () Over ( partition by row1 , row2 , row3 order by row1 ) as RowNumber FROM   YourTable ) delete from duplicate where RowNumber >= 2