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

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
T
Threat Research - Cisco Blogs
小众软件
小众软件
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Tailwind CSS Blog
Cisco Talos Blog
Cisco Talos Blog
V
V2EX
博客园 - 【当耐特】
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
S
Secure Thoughts
O
OpenAI News
P
Proofpoint News Feed
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
T
Tenable Blog
A
Arctic Wolf
L
LINUX DO - 热门话题
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
博客园 - Franky
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
博客园_首页
雷峰网
雷峰网
IT之家
IT之家
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
H
Heimdal Security Blog

博客园 - 代码乱了

MIT 18.06 线性代数 - 23微分方程,exp(At) MIT 18.06 线性代数 - 22. 对角化和矩阵的幂 测试markdown发布 visual webgui theme designer 健身视频 2012元旦遭遇坑爹的12306订票网站付了款不出票 博文阅读密码验证 - 博客园 ReportViewer 2008 打印出现Error loading resource library. (0x8007007E)和(0x80070006) 博文阅读密码验证 - 博客园 VM.xPort.ExcelClient XXX备忘 Parsing html markup text using MSHTML Serialize and Deserialize RDL Winform Field interface 转换前台javascript传递过来的时间字符串到.net的DateTime 博文阅读密码验证 - 博客园 SQL:获取正在执行的SQL语句 博文阅读密码验证 - 博客园 VSX vsct file context menu for script editor - 代码乱了 MSChart出现为ChartImg.axd 执行子请求时出错 - 代码乱了 - 博客园
利用XML转换为table实现在SQL参数中传递表结构
代码乱了 · 2010-08-23 · via 博客园 - 代码乱了

SQL 2005中,通常会用到在SQL参数中传递表结构,最简单的办法是利用XML转换为table

代码

DECLARE    @h INT,
    
@XML VARCHAR(8000),
    
@2k5 XMLSELECT    @XML =    '
            <jrt>
                <item>
                    <id>11</id>
                    <name>CS Tester</name>
                    <company>EEE</company>
                    <phone>555-555-1234</phone>
                </item>
                <item>
                    <id>22</id>
                    <name>CS Tester</name>
                    <company>EEE</company>
                    <phone>555-555-1234</phone>
                </item>
            </jrt>
        
',
    
@2k5 = @XMLSELECT    T.c.query('id').value('.[1]''varchar(100)'as id,
        T.c.query(
'name').value('.[1]''varchar(50)') as name,
        T.c.query(
'company').value('.[1]''varchar(50)') as company,
        T.c.query(
'phone').value('.[1]''nvarchar(50)'as phone
FROM    @2k5.nodes('/jrt/item'AS T(c)

 结果是:

id         name       company    phone
---------- ---------- ---------- ----------
11         CS Tester  EEE        555-555-12
22         CS Tester  EEE        555-555-12