sqlserver 中openxml如何适用exec执行
sqlserver吧
全部回复
仅看楼主
level 2
斜风无痕 楼主
----读取xml数据
declare @fields varchar(255)
set @fields='LVno,status'
declare @xmlstr nvarchar(max)
set @xmlstr='<doc><row LVno="LVBH201500001" status="大修"/><row LVno="LVBH201500002" status="养护"/></doc>'
exec('select top 1 '+@fields+' into TT from tablename')
declare @idoc int
EXEC sp_xml_preparedocument @idoc OUTPUT, @xmlstr
exec(' select * from openxml('+@idoc+',''doc/row'') with TT' )
EXEC sp_xml_removedocument @idoc
drop table TT
[Err] 42000 - [SQL Server]'1' 附近有语法错误。
如果是select * from openxml(@idoc,'doc/row') with TT 这样是没问题的,但
使用 exec(' select * from openxml('+@idoc+',''doc/row'') with TT' ) 就错了
第一次使用openxml,求大神帮忙解决一下
2015年06月01日 01点06分 1
1