while 루프에서 동적 테이블을 업데이트하고 싶습니다.저장 프로 시저에서 while 루프를 사용하여 테이블을 업데이트하는 방법?
While (@j<[email protected]_getRowCount)
Begin
Set @firstcolumn = (Select SplitFirst_tblAR from @result_AR Where rownumber = @j) //String//
Set @secondcolumn = (Select EMail_tblAR from @result_AR Where rownumber = @j) //String//
Set @thirdcolumn = (Select SplitFirst_tblKul from @result_AR Where rownumber = @j) //String//
Set @fourthcolumn = (Select EMail_tblKul from @result_AR Where rownumber = @j) //String//
insert into @test Values(@tmp_ID, @firstcolumn,@secondcolumn,@thirdcolumn,@fourthcolumn)
if ((@firstcolumn = @thirdcolumn) AND (@secondcolumn != @fourthcolumn) AND (@firstcolumn != ''))
begin
Set @q_updateTable = 'Update '+ quotename(@tablename) +' Set '[email protected]+' = ''' + @fourthcolumn + ''' Where ID = ' + @tmp_ID + ''
Exec sp_executesql @q_updateTable
end
SET @j = @j+1
End
내 result_AR 테이블 :
나는 오류가 알고 여기에 :
어디 ID = '+ @tmp_ID 여기
내 코드입니다 + ''
내가 절
같은 경우 '+ @ 럼 이름 +'= '' '+ @secondcolumn +' '' '
코드를 어디에서이 변경3210 올바르게 작동합니다.
ID로 내 where 절을 설정할 수없는 이유는 무엇입니까? 나는 정수로서 ID 값을 얻는다. 오류가 '쿼리가 오류로 완료되었습니다.'입니다. 미리 감사드립니다.
이 변수에 무엇입니까? 그것을 추가 할 수 있습니까? – rbr94
'@tmp_ID '의 데이터 유형은 무엇입니까? –
왜 루프를 이렇게할까요? –