分割字符串,并把它插入表中
create proc sp_InsertSplite (@s text) as begin declare @str nvarchar(100) DECLARE CusCursor CURSOR FOR select col from dbo.f_splitStr(@s,';') OPEN CusCursor FETCH NEXT FROM CusCursor INTO @str WHILE (@@FETCH_STATUS = 0) BEGIN declare @start1 int,@start2 int declare @col1 varchar(50),@col2 nvarchar(50)--,@col3 nvarchar(100) set @start1=charindex(',',@str) set @col1=substring(@str,1,@start1-1) set @start2=charindex(',',@str,@start1+1) set @col2=substring(@str,@start1+1,LEN(@str)-@start2) --set @col3=substring(@str,@start2+1,LEN(@str)-@start2) insert Note(Name,Note) values(@col1,@col2) FETCH NEXT FROM CusCursor INTO @str END CLOSE CusCursor DEALLOCATE CusCursor end