[MSSQL] Row Merge, ?? Row ???
- ???? Row? ? ???? ? ??? ?? ??? ??? ??
1. ????
- CREATE TABLE #TEMP1
- (
- Code INT,
- VALUE VARCHAR(100)
- )
-
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 1, ‘??‘ )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 1, ‘?????‘ )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 1, ‘??‘ )
-
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 2, ‘??‘ )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 2, ‘?????‘ )
- INSERT INTO #TEMP1 (Code,Value) VALUES ( 2, ‘???‘ )
2. FOR XML ??
- SELECT Value
- FROM #TEMP1
- FOR XML PATH(‘‘)
-
- SELECT Value + ‘ ‘
- FROM #TEMP1
- FOR XML PATH(‘‘)
< element ? ?? ?? >
< element ? ? ?? ?? (??? ???? ?? ????)>
3. Column SubQueyr ??
- SELECT Code,(
- SELECT Value + ‘ ‘
- FROM #TEMP1
- WHERE Code = A.Code
- FOR XML PATH(‘‘)
- )
- FROM #TEMP1 A
4. DISTINCT ??
- SELECT DISTINCT Code,(
- SELECT Value + ‘ ‘
- FROM #TEMP1
- WHERE Code = A.Code
- FOR XML PATH(‘‘)
- )
- FROM #TEMP1 A
5. ?? ???? ?? ‘ ‘? ??? ?? Stuff ?? SUBSTRING ? ??? ?? ??
行合并,布布扣,bubuko.com
行合并
原文:http://www.cnblogs.com/ok519/p/3850793.html