Microsoft – SQL Server – Column DataTypes \ Definitions {the weary kind}

Microsoft – SQL Server – Column DataTypes \ Definitions  {the weary kind}

The local BlockBuster Video Rental Store is Closing down.

Just like a kid remembers the local burger place or McDonald’s, I think adults remember the local music stores, the local BlockBuster \ Hollywood Store.

And, I think some of us remember the local  “Barnes & Noble”, Walden Books.  Just to be a able to go in to a book store and see all the books, you will never get to read, but would love to.

Many years ago it was the Client Server {OS\2} books by Robert Orfali and Dan Harkey; San Jose State U lecturers.  Programming Windows Books by Charles Petzold –

A few years ago it was the stack of Java Books – Enterprise Java (EJB).  Today it might be Enterprise Service Bus (ESB) or HTML 5.

But, back to our Weary Kind fable.

A good cover of “Weary Song”  is available @

In Database World, There are some data types or column definitions that are a bit harder to optimize.

In MS SQL Server, they include:

  1. DataTypes – text
  2. Un-persisted  Computed Columns

There are multiple reasons why one needs to review and have peer review of Database tables structural definitions:

The reasons include:

1) Some datatypes are not indexable

2) Some datatypes preclude “Online” Database Operations.  In SQL Enterprise, one can perform online operations such as Index Rebuild, etc.  But, one is unable to do see when a table includes text columns

3) Un-persisted Computed Columns also have to be re-computed each time they are accessed

4) Un-persisted Columns can not be the main key of a partition table

5) Unicode columns (nchar, nvarchar, ntext) help to support Internalization.  But, they also use occupy double the size of their corresponding pair
To identify those columns, one can use a Query that resembles the one below:


       	    when (tblColumn.max_length = -1) 

               then 'Column Length is MaxLength'

	    when (
		  ( in ('text', 'ntext'))
		then 'DataType (Suspect)'

	     when (
		   (tblColumn.is_computed = 1)
		  then 'Computed Column (Unpersisted)'

	     else null 

          end as [reason]

	from   sys.objects tblObject

           inner join sys.columns tblColumn

	     on tblObject.object_id = tblColumn.object_id

	   left outer join sys.computed_columns tblColumnComputed

	    on tblColumn.object_id = tblColumnComputed.object_id
	    and  tblColumn.column_id = tblColumnComputed.column_id	

	   left outer join sys.types tblColumnType

	    on tblColumn.system_type_id
                     = tblColumnType.system_type_id

	where  tblObject.type in ('U')

	and    (

		   -- max data types
		   (tblColumn.max_length = -1) -- Max Data Type



                    --text data types
			( in ('text', 'ntext')		    )


		 --un-persisted computed columns
		or (
			 (tblColumn.is_computed = 1)				     and (tblColumnComputed.is_persisted = 0)

	order by


1) Are there any disavantages to using Nvarchar(max)


3) VARCHAR(MAX) Performance in SQL Server 2008 R2


5) NTEXT vs NVARCHAR(4000) in MS SQL Server v 2005

6) Performance Memo/NText Fields

7) IN-ROW Data

8)NVarchar(max) columns can not be “Unicode” compressed

9) Use Unicode Native Format to Export/Import Data

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your 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