Updating tables within cursor loop

Posted by / 02-Aug-2020 19:22

Hi, I want to know if there is anything wrong that I might be doing in the below piece of code.

[1] I have a table, say, xx_my_big_table_t which could potentially have 100,000 rows.

but now, i am facing problems trying to update the UDT [dbo].[@Bin Stock] from within a cursor fetch loop. */ FETCH NEXT FROM cur1 INTO @t Whcode, @t Itemcode, @tstbin, @tqty END CLOSE cur1 DEALLOCATE cur1 drop table #t St Bin, #m St Bin /* end of query */ though iserting records in the temporary table #m St Bin with the very same insert statement does not give any problems, trying to insert records in the UDT [dbo].[@Bin Stock] with that insert statement results in an error.

on Nov 14th i had asked a question 'UDT updation' as to how & with what values to update UDT's default fields 'Code' & 'Name'.To demonstrate how to use a cursor to update records we'll create a running total of the number of Oscars our films have won.To begin with we'll declare a couple of variables and set their default values.To make things even more specific you can list which columns from the data set you would like to make updatable, as shown below: The code above ensures that only one field from the underlying data set can be updated.You can add more column names in a comma-separated list if you need to make more fields updatable.

updating tables within cursor loop-86updating tables within cursor loop-12updating tables within cursor loop-65

So far in this series we've been concerned with simply reading data from tables using a cursor.

One thought on “updating tables within cursor loop”