Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 nvarchar (4000) and max string size

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2006-06-05 : 03:01:50
i have tried to insert into an nvarchar (4000) field a string in the size of 3989
and i got the message " row exceds maximum size 8088 where max allowed 8068"
i checked and verifeid and mystring is 3989!
after i cutted the string to 3938 it all worked fine
any idea why?
(the nvarchar(4000) wasnt defined by me -but by a previous programmer, beacuse i assume in this case - a string of type "34234|324234||454545" a varchar field is enough -which gives 8000 chars instead of 4000)
thnaks in advance
peleg

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

nr
SQLTeam MVY

12543 Posts

Posted - 2006-06-05 : 04:32:32
It's not that string that's the problem it's the max row size which is 8060. The combined size of all the columns in the row is 8088 which is invalid. Dropping the size of that string brought it below the 8060 byte limit.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2006-06-05 : 05:37:17
u mean for example tha i cant defined 2 column s each of size 4000 for example?

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-05 : 07:18:16
quote:
Originally posted by pelegk2

u mean for example tha i cant defined 2 column s each of size 4000 for example?

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)


Yes. Run this
declare @t table(n1 nvarchar(4000), n2 nvarchar(4000))

Also read about Maximum Capacity Specifications in sql server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2006-06-05 : 08:34:23
ok thanks alot

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

PSamsig
Constraint Violating Yak Guru

384 Posts

Posted - 2006-06-05 : 10:18:42
You CAN creater a table like table(n1 nvarchar(4000), n2 nvarchar(4000)), but you can't fill both n1 and n2 to the max at the same time.

-- This one's tricky. You have to use calculus and imaginary numbers for this. You know, eleventeen, thirty-twelve and all those.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-05 : 10:22:38
quote:
Originally posted by PSamsig

You CAN creater a table like table(n1 nvarchar(4000), n2 nvarchar(4000)), but you can't fill both n1 and n2 to the max at the same time.

-- This one's tricky. You have to use calculus and imaginary numbers for this. You know, eleventeen, thirty-twelve and all those.


Thanks. Thats what I wanted to tell the questioner

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

PSamsig
Constraint Violating Yak Guru

384 Posts

Posted - 2006-06-05 : 10:24:15
And yes, if the string '34234|324234||454545' is representative for the type of what you save in your nvarchar coloumn, then there is no reason you reconfigure it to varchar(8000), that would give you twice the max size.

-- This one's tricky. You have to use calculus and imaginary numbers for this. You know, eleventeen, thirty-twelve and all those.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-05 : 10:41:44
pelegk2, you need to read about normalisation
http://www.datamodel.org/NormalizationRules.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cmdr_skywalker
Posting Yak Master

159 Posts

Posted - 2006-06-05 : 22:36:41
NVARCHAR is UNICODE VARCHAR. NVARCHAR(4000) is storage equivalent of VARCHAR(8000). As Madhivanan said, check the BOL for Maximum Capacity Specification.

May the Almighty God bless us all!
Go to Top of Page
   

- Advertisement -