通过xml将传入的字符串转成表格列值
ALTER PROC spitString ( @Param VARCHAR(MAX) )
AS
BEGIN
DECLARE @x1 XML
SELECT @x1 = CONVERT(XML, '<v>'
+ REPLACE(REPLACE(REPLACE(REPLACE(@Param, ',', '</v><v>'),
CHAR(13), ''), CHAR(9), ''),
CHAR(10), '') + '</v>')
SELECT N.v.value('.', 'varchar(20)') AS id
INTO #t1
FROM @x1.nodes('/v') N ( v )
SELECT *
FROM #t1
DROP TABLE #t1
END
EXEC spitString @Param = '17487026,17466740,
17487428, 17430104, 17443886,
17486138, 17385494, 15947798, 17487338, 17467616,
8203610, 15732698, 17476700, 6859904, 17311190,
5846780, 17488190, 17488214, 17488466, 17048114,
17486690, 16065794, 17244860, 17228876, 6850346,
7479974, 8876840, 16159610, 17165546, 17279042,
6212600, 5606228, 17490794, 16335278, 17491196,
17479688, 15585458, 16488440, 8051666, 17172494,
16559432, 7890902, 16810304, 5301914, 9714686,
17492510, 7431980, 15528512, 16435322, 17283398,
17493254, 17491802, 15092630, 17405516, 16439954,
5805092, 17101634, 2577680, 8881556, 16066820,
5454776, 2610932, 15094772, 4674206, 7874060,
16964630, 17497016, 16290332, 8817008, 8054174,
6638960, 7345076, 1577978, 9135428, 17498384,
9687668, 16809932, 6383264, 8059370, 9406382,
17497934, 15130724, 17008988, 9871778, 15081992,
8595404, 1673756, 4019126, 15901142, 9240830,
17496686, 4761020, 8743298, 6947936, 9207464,
17502554, 17503244, 8135612, 17503808, 9576308,
15044024, 6695564, 16123232, 2830376, 9529292,
9617558, 1661894, 9775010, 17356448, 3624902,
6447752, 15400100, 4348640, 7699652, 5281964,
17411348, 17325782, 5155442, 16796774, 15372224,
8494742, 3921902, 6169346, 17493890, 16145330,
17346080, 6877898, 17494964, 16736636, 7983110,
8122142, 17509400, 15811340, 16197326, 6876716,
17322302, 8959274, 17511758, 8954900, 7608506,
6616094, 6381326, 16728848, 15254504, 8117582,
15591968, 9968708, 17385680, 16078196, 17513624,
6532652, 16829876, 17443256, 6511796, 7588688,
17512274, 6733796, 17477078, 8215184, 6213530,
15444254, 17514572, 15802820, 17420000, 9537740,
8924678, 16610030, 17514404, 9737300, 6720554,
17516312, 17251058, 17362340, 17512028, 5002202,
17470040, 17515772, 8846612, 17405732, 8767544,
17438450, 7939526, 9515042, 17518346, 17518472,
16196096, 17516744, 8445416, 17519108, 7593692,
17518790, 9526916, 16742402, 16174136, 9535028,
17452370, 7785614, 6371018, 17452478, 9335714 '