May 07, 2009

Find Out Tables in a Database Having Identity Columns

The simplest way I use to find out the tables in SQL Server 2005/2008 having Identity Columns is to use the query over here

USE Northwind


SELECT object_name(o.object_id) AS TableName, as IdentityColumn

FROM sys.columns c JOIN sys.objects  o

ON c.object_id = o.object_id

WHERE is_identity = 1

AND o.type IN ('U')


TableName    IdentityColumn

Categories    CategoryID

Shippers    ShipperID

Suppliers    SupplierID

Orders        OrderID

Products    ProductID

Employees    EmployeeID

Did you like this post?
kick it on
subscribe via rss subscribe via e-mail
print this post follow me on twitter

About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal



0 Responses to "Find Out Tables in a Database Having Identity Columns"

Copyright © 2009-2014 All Rights Reserved for by Suprotim Agarwal | Terms and Conditions