dbTalk Databases Forums  

Identity Column in INFORMATION_SCHEMA or the sys tables

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


Discuss Identity Column in INFORMATION_SCHEMA or the sys tables in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Wing9897@hotmail.com
 
Posts: n/a

Default Identity Column in INFORMATION_SCHEMA or the sys tables - 09-10-2007 , 09:13 AM






Hello,

Where can one find the identity column for a table in the
INFORMATION_SCHEMA or the sys tables? Or is there a function that can
return the name or id of the identity column for a particular table?
Thanks.


Reply With Quote
  #2  
Old   
kb
 
Posts: n/a

Default Re: Identity Column in INFORMATION_SCHEMA or the sys tables - 09-10-2007 , 12:11 PM






Quote:
Where can one find the identity column for a table in the
INFORMATION_SCHEMA or the sys tables? Or is there a function that can
return the name or id of the identity column for a particular table?
SELECT name
FROM sys.columns
WHERE object_id=OBJECT_ID('dbo.YourTableHere','U') AND is_identity=1


--
Tom
http://kbupdate.info/ | http://suppline.com/




Reply With Quote
  #3  
Old   
kb
 
Posts: n/a

Default Re: Identity Column in INFORMATION_SCHEMA or the sys tables - 09-10-2007 , 12:15 PM



Quote:
Where can one find the identity column for a table in the
INFORMATION_SCHEMA or the sys tables? Or is there a function that can
return the name or id of the identity column for a particular table?

SELECT name
FROM sys.columns
WHERE object_id=OBJECT_ID('dbo.YourTableHere','U') AND is_identity=1

SQL 7.0 / 2000 version:


SELECT name
FROM dbo.syscolumns
WHERE id=OBJECT_ID('dbo.YourTableHere','U') AND
COLUMNPROPERTY(id,name,'IsIdentity')=1


--
Tom
http://kbupdate.info/ | http://suppline.com/




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.