xml - SQL Server String or Binary data would be truncated varchar(max) -


i have seen question posted numerous times, none seem address variant of problem.

msg 8152, level 16, state 14, line 150
string or binary data truncated.

is error getting while pulling data xml variables.

the xml structure (simplified) following:

<view>     <view_config>         <gl_type>box</gl_type>         <data_access>             <access_as></access_as>             <access_id></access_id>             ...         </data_access>         <data>             <dimension x="1" y="2" z="3" />             <is_position_relative>false</is_position_relative>         </data>     </view_config>     <view_config>     ...     </view_config> </view> 

where in data-set xml gives issue has 168 nodes. error occurs 27 times , while parsing particular xml data code:

declare @graphics table(     rownum int identity(0,1)primary key clustered,     graphicname varchar(max),     vcxml xml,     numcomponents int ) declare @viewconfigs table(     rownum int identity(0,1)primary key clustered,     graphicname varchar(max),     viewindex int,     gl_type varchar(max),     access_as varchar(10),     ...     dimx float, dimy float, dimz float,     posrelative varchar(max) )  insert @graphics(graphicname,vcxml) (select graphic_name,viewcenter_config projauto_graphics) order graphic_name  declare @m int, @n int declare @xml xml set @m = 0 select @n = count(*) @graphics while @m < @n begin     update @graphics     set numcomponents = (select max(vcxml.value('count(//view_config)','int'))     @graphics rownum = @m     set @m = @m + 1 end set @m = 0  select @xml = vcxml @graphics rownum = @m  declare @graphicname varchar(30) declare @gltype varchar(30) --increased these values while trying debug. declare @dimx float, @dimy float, @dimz float declare @rltv varchar(max) --other variables needed fill in table  declare @data table(     rownum int identity(0,1)primary key clustered,     dx float, dy float, dz float,...,rltv varchar(max) )--i had make table due nested structure of xml  while @m < @n --this loops on each graphic in table begin     select @xml = vcxml @graphics rownum = @m     insert @data     select         tbl.col.value('(dimension/@x)[1]','varchar(max)'),         tbl.col.value('(dimension/@y)[1]','varchar(max)'),         tbl.col.value('(dimension/@z)[1]','varchar(max)'),         tbl.col.value('(is_position_relative)[1]','varchar(max)')     @xml.nodes('//data') tbl(col)      declare @i int, @j int     set @i = 0     set @j = numcomponents @graphics rownum = @m     while @i < @j     begin         --store values @data temp variables make insert statement         select @dimx = dx @data rownum = @i         select @dimy = dy @data rownum = @i         select @dimz = dz @data rownum = @i     print @graphicname -- debugging         select @rltv = rltv @data rownum = @i         insert @viewconfigs(graphicname,gl_type,...,rltv)         values(@graphicname,@gltype,...,@rltv)         set @i = @i + 1     end     set @m = @m + 1 end 

so have gone through every variable use node , made sure set varchar(max), ones used in xquery syntax. have tested query see if there values is_position_relative other false , there not, in addition manually inspecting xml particular graphic causes error occur.

finally when view results in sql server, there no null values in table, let alone non-false values.

what still causing error, , result of error occurring (because doesn't seem mess results)?


Comments