Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best datatype for SQL table with lots of long text fields

I have the following table in a SQL Server 2008 database with lots of long varchar fields for text descriptions. I want to know what is the best datatype to use for these. Currently I'm using varchar with 2000 character limit but this might cause problems if people need to add more text. Is there a problem using TEXT more than once in a table? What do you suggest?

Table
 name varchar(250)
 description1 varchar(2000)
 description2 varchar(2000)
 description3 varchar(2000)
 description4 varchar(2000)
 description5 varchar(2000)
like image 728
Mark Clancy Avatar asked Sep 07 '25 19:09

Mark Clancy


1 Answers

For SQL Server 2008, I believe the recommended practice is to use varchar(max) rather than text - text is to be deprecated, I believe, in a future SQL Server edition.

Your table design seems sound enough to me, but I suspect some will suggest that if the columns are filled to the max - and the table row count is large - then there might be some performance issues. SQL Server can only store 8K per database page, so it would have to split our your table - which has a performance impact.

like image 147
Peter Schofield Avatar answered Sep 11 '25 00:09

Peter Schofield