Code Createfunction[dbo].[f_split](@SourceSqlvarchar(8000),@StrSepratevarchar(10)) returns@temptable(a varchar(100)) --实现split功能 的函数 as begin declare@iint set@SourceSql=rtrim(ltrim(@SourceSql)) set@i=charindex(@StrSeprate,@SourceSql) while@i>=1 begin insert@tempvalues(left(@SourceSql,@i-1)) set@SourceSql=substring(@SourceSql,@i+1,len(@SourceSql)-@i) set@i=charindex(@StrSeprate,@SourceSql) end if@SourceSql<>'' insert@tempvalues(@SourceSql) return end GO