Find a Table's Metadata

SQL Server stores all of the metadata information that you would ever need to know about a table. However, it is often cumbersome and nominative for programmers to pull out this data using the system tables and special sprocs that are required to find the useful information. I have worked in multiple enterprises where it became my responsibility for keeping track of basic table/field information in a user table despite the fact that this information is readily available in SQL Server's system tables.

Using this procedure, programmers pass in a table name and schema for a user table and receive tuples of fields that contain the data type, length, description, and the lookup table if there is a foreign key constraint. Our programmers now use this sproc to dynamically generate data entry forms based on the table's metadata without having to understand the nuances of how this data is stored in SQL Server.

Our DBAs also use it to gain a quick glimpse into how a table is designed without using the graphical tools of Management Studio or Enterprise Manager.The procedure could be tailored to output additional information specific to a program/organization.

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands
of articles and SQL scripts, a library of free eBooks, a weekly database news roundup,
a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals
that makes it such a success.