Solved

SQL column  ntext, nvarchar

Posted on 2010-09-08
11
702 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
 
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
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: 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now