当前位置: 代码迷 >> Sql Server >> for xml path()有长度限制吗?解决思路
  详细解决方案

for xml path()有长度限制吗?解决思路

热度:42   发布时间:2016-04-27 14:01:20.0
for xml path()有长度限制吗?
测试数据:
SQL code
if object_id('tempdb..#t') is not null    drop table #tcreate table #t(a nvarchar(50))declare @a intset @a = 1while @a <= 120begin    insert into #t(a) values('Employees.Number as [工號]★')    set @a = @a + 1end--print len('Employees.Number as [工號]★') * 120select '' + 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 intset @a = 1while @a <= 120begin    insert into #t(a) values('Employees.Number as [工號]★')    set @a = @a + 1endselect len('Employees.Number as [工號]★') * 120 'len1'select len((select '' + a + '' from #t for xml path(''))) 'len2'len1-----------3000len2--------------------3000
------解决方案--------------------
如果正常的长度是8000呢??出来的长度是多少?
------解决方案--------------------
你数据库的查询选项--结果--网格 里面检索最多的字符数XML数据设置大一点


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

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

------解决方案--------------------
SQL code
if object_id('tempdb..#t') is not null    drop table #tcreate table #t(a nvarchar(50))declare @a intset @a = 1while @a <= 120begin    insert into #t(a) values('Employees.Number as [工號]★')    set @a = @a + 1end-- print len('Employees.Number as [工號]★') * 120select '' + 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 [工號]★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 [工號]★')/*-----------3002(1 行受影响)*/
  相关解决方案