Solved

SQL column  ntext, nvarchar

Posted on 2010-09-08
11
705 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:tampsystems
  • 4
  • 4
  • 3
11 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33627471
nvarchar(max) will do.
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 33627475
I'd use nvarchar(max).

Lee
0
 

Author Comment

by:tampsystems
ID: 33627521
that would allow for 4000 characters correct?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 25

Expert Comment

by:Lee Savidge
ID: 33627535
It allows for 2gb
0
 

Author Comment

by:tampsystems
ID: 33627549
so if we set a maxlength of 5000 characters i the UI we will be safe, and we would not have any perfomance issues?
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 33627561
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
0
 

Author Comment

by:tampsystems
ID: 33627577
ok, but i should still limit the UI to restrict the entry of more then 5000 charaters, right?
0
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 250 total points
ID: 33627601
That bit is up to you to be honest. Personally I would always limit the amount of text that a user can send to a database.

Read here for info on nvarchar(max) vs ntext

http://www.west-wind.com/weblog/posts/207.aspx

Lee
0
 

Author Comment

by:tampsystems
ID: 33628422
Can we fit 10,000 characters wth nvachar(max)?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33633972
yes, no problem. the "max" stands for 2GB of data, so 1 000 000 000 characters for Nvarchar
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
ID: 33633977
actually, to be exact (2^31) -1
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question