标签:
create proc PrintStrArr
@Str nvarchar(2000),
@Split varchar(1)
as
declare @PosiInt int
declare @StrCopy nvarchar(2000)
declare @StrItem nvarchar(200)
declare @ErrorNum int
set @ErrorNum=0
begin tran
if LEN(@Str)>0
begin
set @StrCopy=@Str
while len(@StrCopy)>0
begin
set @PosiInt= CHARINDEX(@Split, @StrCopy)
if @PosiInt>0
begin
set @StrItem=LEFT(@StrCopy,@PosiInt-1)
set @StrCopy=RIGHT(@StrCopy,len(@StrCopy)- @PosiInt)
Print @StrItem
set @ErrorNum=@ErrorNum+@@ERROR
end
else
begin
set @StrItem=@StrCopy
set @StrCopy=‘‘
print @StrItem
set @ErrorNum=@ErrorNum+@@ERROR
end
end
end
if (@ErrorNum<>0)
begin
rollback tran
return 0
end
else
begin
commit tran
return 1
end
标签:
原文地址:http://www.cnblogs.com/sdpdf/p/4668320.html