Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to determine if a SQL table has an identity column
Message
 
 
To
09/03/2000 18:38:58
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00343873
Message ID:
00343981
Views:
29
>I 99% answered my own question
>
>select top 1;
>      ident_seed('mytable'),;
>      ident_incr('mytable'),;
>      identitycol ;
>     FROM mytable
>
>
>Row 1, col 1 of my result set is indenty seed.
>Row 1, col 2 of my result set is indentity increment.
>Row 1, col 3 of my result set does not contain the answer: The identity name is the NAME of column 3, not the contents.
>
>The damn thing is doing exactly what I told it to, instead of reading my mind and doing what I want it to <g>.
>
>So what is the syntax to get that identity column name into the result set, rather than just the name of a column?

This might help alittle. You can get a result set of all identity columns in your table using the following:
select sysobjects.name,syscolumns.* from sysobjects inner join syscolumns
   on syscolumns.id = sysobjects.id where syscolumns.autoval is NOT NULL and 
   sysobjects.name = 'mytablename'
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform