Converting from varchar to Text column

We have an MS Access front end to a SQL Server 2000 database. One of the tables has a notes field, which according to our users is not large enough (it's currently the max # characters supported by varchar data type).

I've been asked to enlarge it, which means using Text data type. I'm wondering if there are any issues I need to be aware of before making this change. E.g., LEN doesn't work with Text, DATALENGTH has to be used instead.

Is there anything else? I've done some preliminary tests, and all seems to be ok, but I would like to be sure.

Thanks for any assistance with this,

Tom
LVL 1
TomT49Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ram2098Commented:
The text datatypes cannot be processed in the same way as (n)(var)char datatypes. You cannot use them in functions as you would with chars , nor can you use then in WHERE clause.

e.g. you cannot do

SELECT LEFT(textcol, 3)

SELECT * FROM MyTable WHERE textcol = 'this is a long piece of text.......'

nor can you sort them.

if they are < 8000 chars long, you can cast them to varchar to process them - e.g. WHERE convert(varchar(8000), textcol) = 'this is a long piece of text...' etc, but this will slow down your queries substantially.

As you know, Varchar you can use up to 8000 chars..so use TEXT data type only if it is necessary.
0
ram2098Commented:
Adding more to this...

By default, the text, ntext, and image data types don't store their data in the row like the other fields of that row do. Instead, they store a 16 byte pointer that redirects SQL Server to another 8 K page(s) where the data can be found.

since SQL Server must retrieve two or more pages (verses only one page for rows without any text/image data) using the text, ntext, and image data types slows SQL Server down.
0
TomT49Author Commented:
Thanks for your responses. I would prefer to avoid using this if at all possible, the problem is our sales staff want to be able to put in unlimited notes (at least more than they can now - 8000 chars) for line items in orders.

We do business primarily the government, and apparently things get very complicated.

Short of telling them no, I'm not sure what the solution could be. Is the performance hit that noticeable? Is there any way to measure the impact?
0
ram2098Commented:
If you are sure of using not using this field in any search criteria's (just a simple select if needed), then it is fine to use TEXT data type. But, if you are not sure of this, as you said better to avoid. Performace impact depends on your database size and the kind of queries you execute.

Another solution would be (not sure whether it is feasible in your case), split this text into two fields and store in the database..(like field1 varchar(8000), field2 varchar(8000)). Not sure how the user enters this, you can have it in the same way in your application too.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
muzzy2003Commented:
Or set up a child Notes table, with multiple varchar(8000) records and some sort of process to chunk up long notes and stick them back together, probably in the application code rather than on the SQL Server box.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.