Knee Deep in Tables

Challenge

When working with large databases with LOTS of tables, it can be hard to find a specific discreet data element or column. You know it’s in there somewhere but not exactly where… Your only (sane) option is to turn to the SQL Server system tables to find what you need.

Solution

This SQL query will help you hunt down what you need…


SELECT A.NAME AS [Table Name]
 ,SCHEMA_NAME(schema_id) AS [Schema Name]
 ,B.NAME AS [Column Name]
 ,C.numberofRows
FROM sys.tables AS A
INNER JOIN sys.columns B ON A.OBJECT_ID = B.OBJECT_ID
INNER JOIN dbo.TableSizes C ON A.NAME = C.tableName
WHERE B.NAME LIKE '%Mds%' --<< Guess your column name here

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s