Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data type: Text vs VarChar (10000)

Status
Not open for further replies.

Zirak

MIS
Feb 3, 2003
164
US

I have a table that is used to archive communications.
One of the fields is ComText, I've used the "Text" data type for this field.
Now my question is if I use a varchar data type with the length of (10000) would it improve performance in any way (specialy for reporting purposes)?

 
Using varchar is more efficient than using text. The maximum length for a varchar column is 8000.
 
I believe the maximum VARCHAR can be set to is 8000.

-SQLBill
 
Why is Varchar more efficient and in what situations is it preferred over Text when you have large text data.

Thank you
 
If you have a text column, the actual data is not stored in the table. It is only an adress so the server needs to do one or more additional read to get the contents of the column.

If your data is less than 8000 characters, use varchar.
 
background. The limit to the size of a field (char, varchar, etc) is do to the fact that the width of a row can not exceed the size of a datapage or more exactly that a row can not span datapages. In SQL 7 this was 4k in 2000 it is 8k. Image and Text column are excluded because they are not stored in the datapage with the rest of the row but elsewhere and a pointer, as swampBoogie points out, is stored. Because of this to read that row more data pages will have to loaded. Also any columns that are TEXT and IMAGE are NOT logged.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top