Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Changing varchar to text

Author  Topic 

Skydolphin
Starting Member

43 Posts

Posted - 2004-10-21 : 15:18:38
Hi,

I have a data field that can be quite long. It's very long text. I have the field defined as varchar(8000) now but it still sometimes truncates. My question is, if I change the field to text will I lose the data that is there currently and do I need to do anything different to my select, insert, and update statements?

Currently my sql statements look something like this.

INSERT into SavedResults (User, Text, MakePublic, ResultsName, CreatedDate, Age) VALUES ('FOO', 'This is the long text field', 1, 'foobar', '10/10/04', '120')

Update SavedResults Set User = 'FOO', Query = 'This is the long text', Age = '120' WHERE ResultsName= 'foobar'

select * from SavedResults where ResultsName= 'foobar' AND User = 'FOO'

Any help would be greatly appreciated ASAP.

Thanks.

Rhonda

Rhonda

Kristen
Test

22859 Posts

Posted - 2004-10-22 : 01:33:21
Should be no problem with the modification of the table from varchar to text datatype - data should be preserved (I can't think of HOW data would be lost, but doing a backup will do no harm, right?!)

Your INSERT and UPDATE should be fine too - but a test before doing it for real would do no harm ... !

Your SELECT may cause problems. Some application environments only transfer part of the text, and you have to mess around doing GETCHUNK and stuff to get the rest of it. The general concensus is that most environments work OK if the TEXT column is the last one in the SELECT list. Make sure you have up-to-date ADO drivers, and make an experiment - test with a piece of text bigger than 64K. QA will only display a max of 8000 characters, EM even less (it just says "<longtext>" in cells with lots of text)

I know you've just put an example above, but you shouldn't be using SELECT * ... you need to name the columns in a SELECT statement, and also put any TEXT column last in the list.

Kristen
Go to Top of Page
   

- Advertisement -