Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

How to find all identity columns in SQL Server

07 February,2023 by Tom Collins

Question: How to find all identity columns in SQL Server?

Answer: 

USE myDB;
SELECT 
  SCHEMA_NAME(o.schema_id) AS [schema],
  OBJECT_NAME(idc.object_id) AS [object],
  o.type_desc,
  idc.name,
  idc.seed_value,
  idc.increment_value,
  idc.last_value
FROM sys.identity_columns idc 
INNER JOIN sys.objects o 
ON o.object_id = idc.object_id
ORDER BY SCHEMA_NAME(o.schema_id) ASC;


Find other useful SQL Server object details 

List Foreign Keys referencing tables in SQL Server

What are the triggers in SQL Server

How to find default values of all SQL Server columns

How to find computed columns on a SQL Server table

Find SQL Server LOB Columns


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to find all identity columns in SQL Server


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer