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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SS2K8, but nvarchar(8000) invalid?

Status
Not open for further replies.

SQLJoe

Technical User
Dec 8, 2010
43
US

I am running SQL 2008, but the database is not allowing me to set a length for nvarchar greater than 4000, even though all the documentation I've seen says it will accept up to 8000. I'm sure this is something simple I'm overlooking.

My statement:
alter table dbo.tblWPDataFile2
alter column local_program_text_1 nvarchar(8000)

Error message:
Msg 2717, Level 16, State 2, Line 1
The size (8000) given to the parameter 'local_program_text_1' exceeds the maximum allowed (4000).

I don't want to use ntext because it is deprecated, and I don't want to use nvarchar(max) unless absolutely necessary. According to all I've seen, I shouldn't have to use either of these because nvarchar(8000) should be valid.


 
VARCHAR goes to 8000
NVARCHAR is unicode, takes twice the space, therefor goes to 4000.

You can use NVARCHAR(MAX) if needed.
 

Ah, gotcha. I knew it had to be something simple I was overlooking. Unfortunately I've since tried nvarchar(max) and am still getting truncation errors, which tells me something more fundamental must be going on, since the text couldn't possibly be anywhere near that long. I'm going to have to look into it further.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top