IN A table1 I WANT TO BUILD A TRRIGGER THAT WILL UPDATE ONE FIELD OF OTHER table2 where table2 has Fields: Code Varhar(7) EXIST1 Float EXIST2 Float Exist3 Float Exist4 Float
table1 updates one field of table2 depending on case 1,2,3,...9
declare @code as nvarchar(15) set @code='003' declare @Arm int declare @Result float set @arm=1 Declare @cmd as varchar(2000) set @cmd = 'DECLARE RegCur CURSOR for Select exist'+cast(@arm as nvarchar(1)) +' from tb201 where codigo='''+@code +'''' EXEC (@cmd) OPEN RegCur; DECLARE @exist float FETCH NEXT FROM RegCur INTO @exist; set @total= cast(@exist as Varchar(11)) CLOSE RegCur DEALLOCATE RegCur; print @Result GO