Tables which does not have identity column defined on it

Is there a way we can find the Tables that does not have identiy increment constraint defined on it's primary key colum ?
dumpalprAsked:
Who is Participating?
 
Anthony PerkinsConnect With a Mentor Commented:
Something like this:
SELECT	SCHEMA_NAME(t.schema_id), t.name
FROM	sys.tables t
	LEFT JOIN (
		SELECT	ic.object_id
		FROM	sys.identity_columns ic 
			INNER JOIN sys.key_constraints kc ON ic.object_id = kc.parent_object_id
		WHERE	kc.type = 'PK'
		) c ON t.object_id = c.object_id
WHERE c.object_id IS NULL

Open in new window

0
 
dumpalprAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.