如何在sql中查询xml字符串
2010-01-15 17:26
423 查看
今天第一次尝试用xpath去搜索xml字符串,把自己写的sql帖在下面,以后参考
WITH XMLNAMESPACES (
'http://www.gamingstandards.com/s2s/schemas/v1.2.6/' AS s2s,
'http://s2s.igt.com/player-ext1/v1.0.0' as p1)
select cast(body as xml).value('(/s2s:s2sMessage/s2s:s2sBody/s2s:player/s2s:playerInfo/@p1:playerId)[1]','varchar(50)') from dbo.s2sOutBound_Complete
where cast(body as xml).exist('/s2s:s2sMessage/s2s:s2sBody/s2s:player/s2s:playerInfo') =1
WITH XMLNAMESPACES (
'http://www.gamingstandards.com/s2s/schemas/v1.2.6/' AS s2s,
'http://s2s.igt.com/player-ext1/v1.0.0' as p1)
select cast(body as xml).value('(/s2s:s2sMessage/s2s:s2sBody/s2s:player/s2s:playerInfo/@p1:playerId)[1]','varchar(50)') from dbo.s2sOutBound_Complete
where cast(body as xml).exist('/s2s:s2sMessage/s2s:s2sBody/s2s:player/s2s:playerInfo') =1
相关文章推荐
- [已解决]:通过sql for xml查询到的xml字符串,如何存为标准格式的xml文件?
- SQL查询-将列转换成字符串(for xml path)
- SQL 字段charindex,stuff,ltrim, for xml path('') 操作字符串 合并查询结果项值
- T-SQL操作XML 数据类型方法 "modify" 的参数 1 必须是字符串文字。
- 如何使用sql查询数据库表结构的设计(sqlserver,oracle)
- 如何在 Linux 上用 SQL 语句来查询 Apache 日志
- 如何使用sql查询数据库表结构的设计(sqlserver,oracle)
- SQL 截断字符串查询(CharIndex()函数)
- sql 查询XML示例
- 优化SQL查询:如何写出高性能SQL语句
- SQL不定条件的查询, 数据库拆分字符串
- 你如何获取浏览器URL中查询字符串中的参数?
- SQL 2000 如何优化查询语句,提高查询效率.
- 优化SQL查询:如何写出高性能SQL语句
- 如何从XML字符串获取DataSet
- 如何在Excel中进行类似SQL的查询
- 优化SQL查询:如何写出高性能SQL语句1
- 如何利用SQL查询语句从SQLSERVER数据库中导入导出EXCEL表格
- MSSQL中如何用SQL语句查询字段类型?
- 金蝶KPGETSQL SQL查询语句返回空记录如何解决