To find the Identity Key Cloumns in a particular database
SELECT 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
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
Interview Questions,
SQL Information,
SQL Queries,
Undocumented
. You can follow any responses to this entry through the
comments feed
.
Twit This!
