How to get all the Tables with or without an Identity column in Sql Server

Tables with Identity column

Example:


SELECT name 'Table with Identity column'
FROM SYS.Tables
WHERE OBJECTPROPERTY(object_id,'TableHasIdentity') = 1
AND type = 'U'


Tables without Identity column

Example:


SELECT name 'Table without Identity column'
FROM SYS.Tables
WHERE OBJECTPROPERTY(object_id,'TableHasIdentity') = 0
AND type = 'U'

Post a Comment

0 Comments