Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
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)

Column Size Checker

By Richard Doering,

Introduction :

This is a utility to show how well your column sizes suit your data (or vice versa)..

Usage :

By default, the script will run for every table in the database you run it in.

This may prove quite time consuming so set the @SCHEMA and @TABLE variables at the top of the script to the schema and table name respectively to analyse only one table.

Output :

The output is fairly self explanatory i.e. the name of the name, it's rowcount and column details.

For each column, 3 length values are given (where appropriate)

  1. COLUMN_MAX_LENGTH is the defined length of the column.
  2. DATA_MIN_LENGTH is the lengthof the smallest data found in the column
  3. DATA_MAX_LENGTH is the length of the largest data found in the column

I had fun creating it, I hope someone (who isn't using SSIS 2008 Data Profiler!) finds it useful.


Richard Doering

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

How to Specify Length of Output Column in SELECT Stmt?

How to Specify Length of Output Column in SELECT Stmt?


Get longest length of data in a column

Get longest length of data in a column


Generate script to change column length of string datatypes in a DB

This script can be used to generate alter column length of any string data type column(s) in a datab...


Record Length

Record Length of a Float data type


Fixed Length Flat File

I have a flat file with over 200 fixed length columns. Is there a way to easily load them into SQL ...


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.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones