I want to do this in code, not with ALT+F1.
+4
A:
sp_help tablename
In the output look for something like this:
Identity Seed Increment Not For Replication
----------- ------- ------------ ----------------------
userid 15500 1 0
Patrick McElhaney
2008-10-09 20:05:05
Excellent answer! +1, short, yet accurate
sebastian
2008-10-09 20:14:56
+2
A:
Adjust the WHERE
clause to suit:
select
a.name as TableName,
b.name as IdentityColumn
from
sysobjects a inner join syscolumns b on a.id = b.id
where
columnproperty(a.id, b.name, 'isIdentity') = 1
and objectproperty(a.id, 'isTable') = 1
Luke Bennett
2008-10-09 20:15:46
+6
A:
You can also do it this way:
select columnproperty(object_id('mytable'),'mycolumn','IsIdentity')
Returns 1 if it's an identity, 0 if not.
Blorgbeard
2008-10-09 20:16:59