dbTalk Databases Forums  

Is there a way to check if INDENTITY is enabled on a table?

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Is there a way to check if INDENTITY is enabled on a table? in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
CK
 
Posts: n/a

Default Is there a way to check if INDENTITY is enabled on a table? - 11-27-2007 , 11:44 AM






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?

Thanks for any help.

Cheers,

~ck



Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Is there a way to check if INDENTITY is enabled on a table? - 11-27-2007 , 04:44 PM






CK (c_kettenbach (AT) hotmail (DOT) com) writes:
Quote:
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 (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.