当前位置:Gxlcms > 数据库问题 > sqlserver 读取xml 字符串方法

sqlserver 读取xml 字符串方法

时间:2021-07-01 10:21:17 帮助过:2人阅读

 declare @xml xml
 declare @propertyName varchar(50)
 declare @str nvarchar(max)
   set @propertyName = ‘s_Code‘
   set @xml = ‘<root> <row propertyName="s_Code">test</row><row propertyName="s_Posword">admin</row></root>‘
  
   SELECT @str =@xml.value(‘(/root/row[@propertyName=sql:variable("@propertyName")])[1]‘, ‘nvarchar(max)‘)
   select @str
  
  
 declare @xml xml
 declare @propertyName varchar(50)
 declare @str nvarchar(max)
   set @propertyName = ‘s_Posword‘
   set @xml = ‘<root> <row propertyName="s_Code">test</row><row propertyName="s_Posword">admin</row></root>‘  
   SELECT @str =@xml.value(‘(/root/row[@propertyName=sql:variable("@propertyName")])[1]‘, ‘nvarchar(max)‘)
   select @str

sqlserver 读取xml 字符串方法

标签:

人气教程排行