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

for xml path()有长度限制吗?
测试数据:
SQL code

if object_id('tempdb..#t') is not null
    drop table #t
create table #t(a nvarchar(50))
declare @a int
set @a = 1
while @a <= 120
begin
    insert into #t(a) values('Employees.Number as [工號]★')
    set @a = @a + 1
end
--print len('Employees.Number as [工號]★') * 120
select '' + a + '' from #t for xml path('')


正常的长度是3000,但for xml path('')出来的数据长度无论怎么样都只有2033

请问是什么原因造成的,有什么办法解除这种限制,使其正常输出呢?

------解决方案--------------------
还真没注意这个问题。。
------解决方案--------------------
百度看看吧,这个不知道
------解决方案--------------------
SQL code

select len((select '' + a + '' from #t for xml path('')))

/****************

3000

------解决方案--------------------
测试结果都是3000呀,
SQL code

if object_id('tempdb..#t') is not null
    drop table #t
   
create table #t(a nvarchar(50))

declare @a int
set @a = 1
while @a <= 120
begin
    insert into #t(a) values('Employees.Number as [工號]★')
    set @a = @a + 1
end


select len('Employees.Number as [工號]★') * 120 'len1'
select len((select '' + a + '' from #t for xml path(''))) 'len2'


len1
-----------
3000


len2
--------------------
3000

------解决方案--------------------
如果正常的长度是8000呢??出来的长度是多少?
------解决方案--------------------
你数据库的查询选项--结果--网格 里面检索最多的字符数XML数据设置大一点


------解决方案--------------------
探讨

你数据库的查询选项--结果--网格 里面检索最多的字符数XML数据设置大一点

------解决方案--------------------
SQL code
if object_id('tempdb..#t') is not null
    drop table #t
create table #t(a nvarchar(50))
declare @a int
set @a = 1
while @a <= 120
begin
    insert into #t(a) values('Employees.Number as [工號]★')
    set @a = @a + 1
end
-- print len('Employees.Number as [工號]★') * 120
select '' + a + '' from #t for xml path('')


select len('Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Employees.Number as [工號]★Emp