0
正在使用光標來更新我的空列,但它並沒有更新光標沒有更新我的專欄
Declare @Itemcode as varchar(30)
Declare @SLV as varchar(20)
declare cursor1 cursor for
Select Itemcode ,U_SLV from oitm_Clone where sapitem is null and u_slv is null
open cursor1
fetch next FROM cursor1 INTO @Itemcode ,@SLV
WHILE @@FETCH_STATUS = 0
begin
if @SLV is null
begin
declare @sql1 as varchar(max)
set @sql1 = 'Update [dbo].oitm_Clone set sapitem ='''+ @Itemcode +''' where ItemCode='''+ @Itemcode +''' and U_SLV ='''+ @SLV +''''
print @sql1
execute (@sql1)
end
FETCH NEXT FROM cursor1 INTO @Itemcode ,@SLV
end
CLOSE cursor1
DEALLOCATE cursor1
這是正確的嗎? 'sapitem ='''+ @Itemcode +'''' –