Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Information_Schema - Find auto-increment primary key

Status
Not open for further replies.
Jan 9, 2003
147
US
Hi,

I'm using the INFORMATION_SCHEMA tables to get the information to generate Sql statements. One unique problem I've come across is how to identify if a column is an auto-increment field. I need to know this so that I can write the insert statement without this field.

Here's the two queries I'm using so far, but I don't see anything about an auto-increment status...

Code:
SELECT * FROM Information_SCHEMA.columns


SELECT * FROM 
	INFORMATION_SCHEMA.TABLE_CONSTRAINTS, 
	INFORMATION_SCHEMA.KEY_COLUMN_USAGE 
WHERE 
	INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME = INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME 
	AND INFORMATION_SCHEMA.KEY_COLUMN_USAGE.TABLE_NAME = INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME
	AND CONSTRAINT_TYPE = 'PRIMARY KEY'

Any ideas for other information_schema places to look??

Thanks,
FD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top