Create Table GC (Col1 Char (10)) DROP TABLE GC
----------------------------- Treatment parameters declare @str varchar (100) SELECT @ Str = '1, 2, 3, 4 5 '
- Insert processing declare @s varchar (8000) SELECT @ s = 'select' replace (@str, ',', 'union all succ ")
Exec ('INSERT INTO GC (Col2)' @ S '') - = -------------------------
Create Function F_SPLITSTR (@SourceSql Varchar (8000), @ strseprate varchar (10)) Returns @temp table (f1 varchar (100)) as begin declare @i int set @ SourceSQL = RTRIM (Ltrim (@Sourcesql)) set @i = Charindex (@ straseprate, @ SourceSQL) while @i> = 1 begin insert @temp valuees (@ SourceSQL, @ i-1)) set @ SourceSQL = Substring (@Sourcesql, @ i 1, len (@SourceSQL) ) - @ i) set @ i = charindex (@ strsEprate, @ SourceSQL) end if @SourceSql <> 'INSERT @temp valuees (@SourceSQL) Return End - Execute Select * from dbo.f_splitstr ('01, 02, 03 ',', ')