Link to home
Start Free TrialLog in
Avatar of tampsystems
tampsystemsFlag for United States of America

asked on

SQL column ntext, nvarchar

We are designing a table and we need a column to handle 2000 to 5000 characters.  What is the best datatype for this column?  ntext, nvarchar(2000), nvarchar(5000).  We are using SQL 2005 and SQL 2008.
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

nvarchar(max) will do.
I'd use nvarchar(max).

Lee
Avatar of tampsystems

ASKER

that would allow for 4000 characters correct?
It allows for 2gb
so if we set a maxlength of 5000 characters i the UI we will be safe, and we would not have any perfomance issues?
No, just set the column type to be nvarchar(max). You wouldn't be able to do nvarchar(5000) as this will exceed the row size limit.

Lee
ok, but i should still limit the UI to restrict the entry of more then 5000 charaters, right?
ASKER CERTIFIED SOLUTION
Avatar of Lee
Lee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can we fit 10,000 characters wth nvachar(max)?
yes, no problem. the "max" stands for 2GB of data, so 1 000 000 000 characters for Nvarchar
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial