0

我想用光标替换下面的while循环,我尝试了很多例子,但到目前为止我没有成功,你能帮我吗?

set @tableboundary =( select count(*) as counts from @From_T)
 while @counter < @tableboundary
begin
set @Enti = (select Entities from @From_T where id= @counter)
    Insert into @Temp_Tamale ( Entities) select  value FROM MarMo.dbo.udf_ParseInto(@Enti, ',', '', '')
    set @counter = @counter + 1 
end 
4

1 回答 1

2

当您可以使用单个 SQL 语句时,为什么还要使用游标?

Insert into @Temp_Tamale (Entities)
    select value
    from @From_T t cross apply
         MarMo.dbo.udf_ParseInto(t.Entities, ',', '', '');
于 2013-09-16T11:54:00.093 回答