Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Object Explore

By Robin van Schaik,

First run this script is the database where you want to store this procedure
Then you can run the stored procedure with the following statement:

EXEC sp_ObjectExplore 'database.schema.tablename'

You do not need to supply databasename and schema (example: dbo) when table is in same database as this procedure.

If you want additional metrics concerning the distribution of all numeric variables, execute with parameter @distribution='yes'.
EXEC sp_ObjectExplore 'database.schema.tablename'
, @distribution='yes'

If you are only interested in a subset of columns, you can specify them in the parameter @columns
Columnnames must be separated by a comma. You can specify them either with or without brackets []
Columnnames may not contain commas.
EXEC sp_ObjectExplore 'database.schema.tablename'
, @distribution='yes'
, @columns='column1, column2, etc'

Provide summary information and metrics for any column in a given Table/View
Metrics included are:
* Total number of records in Object (Records)
* Number of values in column (Cnt)
* Number of unique values in column (CntDist)
* Number of NULL values in column (NullValues)
* Min and Max value in column (Min/Max)
* Average value in column (Avg)
* Standard Deviation in column (StDev)
* Number of numeric values in column (IsNum)
* Number of integer values in column (IsInt)
Optional metrics (only computed if procedure is executed with parameter @distribution='yes'
* First Quartile/25% (Q1)
* Median (Median)
* Third Quartile/75% (Q3)
* Interquartile range (IQR)
* Skew (Skew)
* Kurtosis (Kurt)

Total article views: 1041 | Views in the last 30 days: 1
Related Articles

NUMA metric strangeness

Observing strange Perfmon metrics related to NUMA


Tracking Business Metrics

There can be more to managing a SQL Server instance than just examining the performance metrics. The...


Guest editorial: SQL Code Metrics

In which Phil Factor toys with the thought of producing quality metrics for SQL code, before dismiss...


Stored Procedure to get column metrics

Hi everyone, I have a quick question to write a stored procedure to get column metrics. The stored p...


Calculating metric distributions

Hi there, Does anyone have any useful code that I can use to show distributions of data ? Here's ...

data exploration    
standard deviation    
statistics (data)