Roman Rehak

SQL Server and things not related

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

SQL Server Sites

Subscriptions

News

eXTReMe Tracker

Post Categories



Tuesday, April 19, 2005 - Posts

Roman's Weekly SQL Server Tip - How to determine whether the table has an identity column in code

I had to do this recently in one of my utility stored procedures so I thought it would make a good tip. If you need to programatically determine whether the table has an identity column, you can use the OBJECTPROPERTY function and ask for the value of the 'TableHasIdentity' property:

SELECT OBJECTPROPERTY(object_id('MyTable'), 'TableHasIdentity')

SQL Server returns 1 if the table has an identity column, 0 if it doesn't.

posted Tuesday, April 19, 2005 8:58 PM by Roman with 699 Comments




Powered by Dot Net Junkies, by Telligent Systems