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

推荐订阅源

S
Secure Thoughts
S
Securelist
P
Proofpoint News Feed
D
DataBreaches.Net
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Project Zero
Project Zero
A
About on SuperTechFans
罗磊的独立博客
WordPress大学
WordPress大学
月光博客
月光博客
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
AI
AI
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security
T
Tor Project blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MyScale Blog
MyScale Blog
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
T
Threat Research - Cisco Blogs
B
Blog RSS Feed
博客园 - 叶小钗
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Simon Willison's Weblog
Simon Willison's Weblog
C
CERT Recently Published Vulnerability Notes
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic

博客园 - KenBlove

错误代码:0x800706BE 解决方法 泛微OA服务器更改IP地址后EMobile出现“调用远端服务器接口时发生错误(122)”的提示 HTTP 错误 404 - 文件或目录未找到 HTTP 错误 401.2 - 未经授权:访问由于服务器配置被拒绝。 优雅还不够,简洁才高效!——用NValidator一句话搞定客户端检测 MyXls初级教程 一个仿PetShop的通用DBHelper类 纯CSS实现底部固定漂浮导航 Access和SQL server开启表间关系,并实现更新或删除母表数据自动更新或删除子表数据 来自微软关于异常处理的17条军规 一个简单的拖动层(兼容IE,FF) SQL Server Profiler过滤本机信息的办法 "The state information is invalid for this page and might be corrupted"错误的一个解决办法 SQL回滚Transaction来调试SQL语句 SQL找出和删除一个表的重复记录 SQL常用判断检测语句 从丑陋到优雅,让代码越变越美续集之服务器端数据校验 关于FireFox记住密码后出现的bug 关于Iframe在IE6下不显示的bug 从丑陋到优雅,让代码越变越美(客户端检测方法思考)
SQL把ID相同的记录合并成同一条记录
KenBlove · 2009-04-03 · via 博客园 - KenBlove

SQL把ID相同的记录合并成同一条记录.需SQL 2005及以上.

Code
DECLARE @Table TABLE(id int, value varchar(10))
INSERT @Table SELECT 1'AA'
UNION ALL SELECT 1'BB'
UNION ALL SELECT 2'AAA'
UNION ALL SELECT 2'BBB'
UNION ALL SELECT 2'CCC'
UNION ALL SELECT 3'AAAA'
UNION ALL SELECT 3'BBBB'
UNION ALL SELECT 3'XXXX'SELECT * FROM(
    
SELECT DISTINCT 
        id
    
FROM @Table
) A
OUTER APPLY(
    
SELECT 
        
[values]= STUFF(REPLACE(REPLACE(
            (
                
SELECT value FROM @Table N
                
WHERE id = A.id
                
FOR XML AUTO
       ), 
'<N value="'','), '"/>'''), 11'')
) N