日期:2014-05-18  浏览次数:20447 次

提示页的长度超过8086kb
我再sql2005定义一个表
create table test
(tid int identity(1,1),
ttextn nvarchar(max),
ttext1 varchar(max),
text1 nvarchar(4000),
text2 varchar(8000)
)
创建成功,并且成功插入数据
查询每个字段里内容的长度
select len(ttextn) as lentext,len(ttext) as lentextn,len(text1) as lentext1,len(text2) as lentext2 from test

执行结果:
lentext lentext lentext1 lentext2
5212 10781 1039 7898
8344 NULL NULL NULL

问题:为什么没提示页的长度超过8060kb

------解决方案--------------------
为什么要提示呢
------解决方案--------------------
没有提示就说明没问题 放心好了 

------解决方案--------------------
因为你用了varchar,而非char类型. varchar是需要时分配空间,故实际数据没有超过8060时不报错.
SQL code

create table test
(tid int identity(1,1),
ttextn nvarchar(max),
ttext1 varchar(max),
text1 char(4000), -- 用char类型.
text2 char(8000)  -- 用char类型.
)

-- 报错信息
Msg 1701, Level 16, State 1, Line 4
Creating or altering table 'test' failed because the minimum row size would be 12011, 
including 7 bytes of internal overhead. This exceeds the maximum allowable table row size of 8060 bytes.