惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
罗磊的独立博客
SecWiki News
SecWiki News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
IT之家
IT之家
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Vercel News
Vercel News
G
GRAHAM CLULEY
D
DataBreaches.Net
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
T
Tenable Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
J
Java Code Geeks
博客园 - Franky
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
Threatpost
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
U
Unit 42
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
B
Blog
腾讯CDC

博客园 - 流云之心

招人啦 - 前端,后台开发专家 为什么不给程序员配好电脑 [翻译] 开发常用小工具介绍 设计模式一 - Simple Factory, Factory Method, Abstract Factory以及Builder模式简述 强制休息程序 - EyeGuardian 眼睛守护者 Beta测试版 定时计划任务方案比较以及通过脚本创建计划任务(SchTasks命令) javascript 将页面上的Table导出保存为Excel (无格式) - 流云之心 Excel Programming (C# + VBA) Part III Excel Programming (C# + VBA) Part II Excel programming (C# + VBA) Part 1 Harry Potter - The Half-Blood Prince 转移阵地了,新地址:http://spaces.msn.com/members/PuGong 关于XMLHTTP object的OPEN方法 smart client优势在那里? (草稿) SQL Server的collation问题 Microsoft Interview Question links 转自http://blogs.msdn.com/chappell/archive/2004/07/20/189364.aspx MSN to expand free e-mail storage to 250MB 用 #inculde file = "../fiel" 报1031错误 用<!--include file = ../ --> 报错误1031
SQL Server中对XML操作
流云之心 · 2011-08-21 · via 博客园 - 流云之心

博客园的账号密码忘了,先放这儿吧

1.    检查XML中节点是否存在
SELECT xmlContent.exist('/Samples/Sample'),
    * FROM xmlTable
WHERE xmlContent.exist('/Samples/Sample') = 1

SELECT xmlContent.exist('/Samples//Name'),
    * FROM xmlTable
WHERE xmlContent.exist('/Samples//Name') = 1

2.    检查节点值是否存在
SELECT TOP 100    *
FROM  xmlTable
WHERE xmlContent.exist('/Samples/Sample[Value=1]') = 1

3.    获取XML某个节点的内容 (类似DOM的OutterXML)
SELECT TOP 100   xmlContent.query('/Samples/Sample/Name'),
   *
FROM  xmlTable

4.    获取指定XML块的内容 (类似DOM的innerText)
SELECT TOP 100   xmlContent.value('(/Samples/Sample/Name)[1]', 'varchar(100)'),
   *
FROM  xmlTable

附:做测试用的数据表和数据的生成SQL
-- 创建测试表
CREATE TABLE [xmlTable](
    [xmlId] [int] IDENTITY(1,1) NOT NULL,
    [xmlName] [varchar](50) NOT NULL,
    [xmlContent] [xml] NOT NULL,
    [xmlDescr] [varchar](2000) NULL
)

-- 初始化数据
-- truncate table xmlTable
DECLARE @iRow int,
        @xmlContent xml,
        @xmlName varchar(50),
        @xmlId int

SET @iRow = 0
SELECT @xmlId = max(xmlid) from xmlTable

if(@xmlId is null)
    SET @xmlId = @iRow + 1

While @iRow < 5
BEGIN
    SET @xmlName = 'Sample' + Convert(varchar(10), @xmlId + @iRow)
    SET @xmlContent = '<Samples><Sample><Name>' + @xmlName+ '</Name><Value>'+ CONVERT(varchar(20), @xmlId + @iRow)
        + '</Value></Sample></Samples>'
    INSERT INTO [xmlTable]
           ([xmlName]
           ,[xmlContent]
           --,[xmlDescr]
           )
     VALUES
           (@xmlName
           ,@xmlContent
           --,<xmlDescr, varchar(2000),>
           )
      SET @iRow = @iRow + 1
END