Finding Identity Key Columns in SQL Server 2005  

Posted by Sandesh Segu in , , ,

Twit This! Share this in Google Reader Share/Save/Bookmark Subscribe

To find the Identity Key Cloumns in a particular database

SELECT Object_Name(Object_IDAS TableName,
Name AS ColumnName,
Seed_Value AS SeedValue,
Increment_Value AS IncrementValue,
ident_current(Object_Name(Object_ID)) AS CurrentValue,
Last_Value AS LastValue
FROM sys.identity_columns
Order by TableName

To find the Identity Key Cloumns in all databases

EXEC sp_msforeachdb 'Use ?

SELECT ''?'' AS DatabaseName, Object_Name(Object_ID) AS TableName,
name AS ColumnName,
Seed_Value AS SeedValue,
Increment_Value AS IncrementValue,
ident_current(Object_Name(Object_ID)) AS CurrentValue,
Last_Value AS LastValue
FROM sys.identity_columns
Order by TableName'

This entry was posted on Tuesday, May 26, 2009 at Tuesday, May 26, 2009 and is filed under , , , . You can follow any responses to this entry through the comments feed .

0 comments

Post a Comment

Place Your Ad Here

To Block this Place for your ad Contact Me @

Contact Me

Visitors