Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Table contains an IDENTITY?

Author  Topic 

poolpie
Starting Member

2 Posts

Posted - 2009-02-19 : 11:28:42
Hello,

In a stored procedure, I need to know if a table contains an IDENTITY.

It seems this information is not in syscolumns.

Do you know where this property is stored?

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-19 : 11:35:03
[code]SELECT name
FROM syscolumns
WHERE COLUMNPROPERTY(id,name, 'isIdentity') = 1
AND OBJECT_NAME(id)='your table name here'
[/code]
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-19 : 11:45:27
Lists all table with Identity Properties:

Select [name] from 
sys.objects Where type = 'U'
and OBJECTPROPERTY(OBJECT_ID([name]),'Tablehasidentity') = 1
and [name] not like 'dt%' and [name] not like 'sys%'
Order by [name]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-19 : 12:02:34
quote:
Originally posted by sodeep

Lists all table with Identity Properties:

Select [name] from 
sys.objects Where type = 'U'
and OBJECTPROPERTY(OBJECT_ID([name]),'Tablehasidentity') = 1
and [name] not like 'dt%' and [name] not like 'sys%'
Order by [name]



for sql 2000 use sysobjects instead of sys.objects


Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-19 : 12:27:17
quote:
Originally posted by visakh16

quote:
Originally posted by sodeep

Lists all table with Identity Properties:

Select [name] from 
sys.objects Where type = 'U'
and OBJECTPROPERTY(OBJECT_ID([name]),'Tablehasidentity') = 1
and [name] not like 'dt%' and [name] not like 'sys%'
Order by [name]



for sql 2000 use sysobjects instead of sys.objects






Y right. Nowdays have a habit in SQL 2005
Go to Top of Page

poolpie
Starting Member

2 Posts

Posted - 2009-02-19 : 12:46:55
Thanks all! ;-)
Go to Top of Page
   

- Advertisement -