Finding AutoIncrement Identity from Information Schema

Finding AutoIncrement Identity from Information Schema

Post by Gary Brewe » Sat, 02 Feb 2002 01:33:50



Hi,

Is there any way to find out if a column in a table is 'autoincrement
(identify)' information from the information_schema or sys* tables?

Regards,

Gary

 
 
 

Finding AutoIncrement Identity from Information Schema

Post by Narayana Vyas Kondredd » Sat, 02 Feb 2002 01:37:58


Gary, try this:

SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMNPROPERTY(OBJECT_ID(TABLE_NAME),COLUMN_NAME,'isIdentity') = 1 AND
TABLE_NAME = 'Your_Table_Name_Here'
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/


Quote:> Hi,

> Is there any way to find out if a column in a table is 'autoincrement
> (identify)' information from the information_schema or sys* tables?

> Regards,

> Gary


 
 
 

Finding AutoIncrement Identity from Information Schema

Post by Dinesh T » Sat, 02 Feb 2002 01:42:11


Gary,

You can use 'IsIdentity' of COLUMNPROPERTY

like
COLUMNPROPERTY(object_id('tablename'),'column_name','IsIdentity' )

will return 1 if true and 0 if not.

Dinesh,


Quote:> Hi,

> Is there any way to find out if a column in a table is 'autoincrement
> (identify)' information from the information_schema or sys* tables?

> Regards,

> Gary

 
 
 

1. Finding KEY information from schema tables ?

Hi,

  How can I recover schema information (such as Primary Key's , COmposite
Keys, Secondary Keys and so on?) from both Oracle and Sybase systems ?

  I've been looking at ODBC, and can see no function that does this. I'm
assuming this information is stored in proprietary system tables, but a
cursory look at a stack of documentation yield no leads....

  Thanks a million,
  Winton

--
-----------------------------------------------------------

WWW:         http://www.csd.abdn.ac.uk/~wdavies/wdavies.html
Telephone    OFFICE: 1-415-725-7469 (USA)  FAX: 1-415-725-7411
Address:     Room 206, Gates, Stanford University, CA 94305, USA

2. DAO v RDO v ADO

3. Help! Need Sql for calculating the values in a totally calculated record

4. Information Schema Views -- index information ?

5. Using Sybase DB-Library and g++ ??

6. Identity burning set factor & Autoincrement

7. : SQL anyware contra SQL server, or autoincrement contra Identity

8. IDENTITY - Field AutoIncrement

9. Getting the value of an autoincrement or identity field during an sql insert

10. Create a trigger for autoincrement ID (NOT Identity)

11. Getting the value of an autoincrement or identity field during an sql insert