Posted by Erland Sommarskog on 11/27/07 22:44
CK (c_kettenbach@hotmail.com) writes:
> Is there a way to check if INDENTITY is enabled on a table?
>
> I want to provide a table name and see if Identity (Autonumber) is enabled
> on it. Is this possible?
There are several ways. The quickest is probably
SELECT CASE WHEN ident_current('tbl') IS NOT NULL
THEN 'Has identity'
ELSE 'Nope'
END
You can also use objectproperty, or look in sys.columns (SQL 2005 only).
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|