Collecting tables information using procedure sp_tables_info | Database Journal

Collecting tables information using procedure sp_tables_info

Written By
Maxim Smirnov
Maxim Smirnov
Dec 12, 2000
1 minute read

Stored procedure sp_tables_info is designed to provide information required for tables’ optimization process. For the database given as a parameter (by default current connected database will be chosen) it will go through each user table and will collect indexes and constrains information.


Proper indexes and constrains implementation strategy is essential for database performance and must be selected very carefully. Constrains support referential integrity between tables. Indexes are used for faster data access.


Procedure will display the following information:

  • Table name
  • Table system ID
  • Existence of the primary key constrains (values 0 or 1) (PKC)
  • Number of unique constrains (UNC)
  • Number of foreign key constrains (FKC)
  • Existence of the clustered indexes (values 0 or 1) (IND_CL)
  • Number of non-clustered indexes (IND_NC)
  • Special flag (*) indicating that clustered index is not defined
  • Number of records in the table (approximate) (ROWCNT)

Most of the tables should have a clustered index, especially if the number of records is large. Generally speaking, each table should have an index, and if there is one, is should be clustered. That is why the flag is implemented to bring your attention to the tables without clustered indexes.


I suggest creating this procedure in master database. This way stored procedure can be called from any connection by any user defined in master database.


If you have any questions or would like to suggest how to improve this procedure feel free to contact me at feedback@databasejournal.com. You input is greatly appreciated.

Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.