Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

Authors

Search

XML Feeds

Google Ads

« SQL Server collation conflictsDo not use the float data type »
comments
Rate Post:
submit to reddit Digg!FacebookDotnetkicks

With SQL Server versions prior to SQL2005, the only way to store large amounts of data was to use the text, ntext, or image data types. SQL2005 introduced new data types that replace these data type, while also allowing all of the useful string handling functions to work. Changing the data types to the new SQL2005+ equivalent should be relatively simple and quick to implement (depending on the size of your tables). So, why wait? Convert the data types now.

The query presented below will display all the columns in all the tables within your database that are text, ntext or image.

How to detect this problem:

  1. SELECT  O.Name,
  2.         col.name AS ColName,
  3.         systypes.name
  4. FROM    syscolumns col
  5.         INNER Join sysobjects O
  6.           ON col.id = O.id
  7.         INNER join systypes
  8.           ON col.xtype = systypes.xtype
  9. WHERE   O.Type = 'U'
  10.         And OBJECTPROPERTY(o.ID, N'IsMSShipped') = 0
  11.         And systypes.name In ('text','ntext','image')
  12. ORDER BY O.Name, Col.Name

How to correct it: Change the data type to a SQL2005+ version. Text should be converted to varchar(max), ntext should be converted to nvarchar(max) and image should be converted to varbinary(max).

Level of severity: Low

Level of difficulty: Easy

About the Author

George has been developing software professionally for 19 years, first for the department of defense, and then for various other companies. In 1998, George started his software company, Orbit Software, specializing in School Bus Transportation software. His specialty is refining SQL Server queries to deliver optimal performance.
Social SitingsTwitterLTD RSS Feed
352 views
submit to reddit Digg!FacebookDotnetkicks

Comments and Feedback

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)