The blog explains a simple cursor in SQL Server to update rows. This is just for explanation, the update query can be written without using cursor too. The T-SQL is given below

The above query updates the orderqty column to 100 for a particular salesorderid. When doing a cursor update the CURRENT OF keyword is used to update the current row. If a cursor definition has a query with multiple tables then only the table used in update statement is affected.  The output of above query is shown below.

1_simple cursor in sql server to update rows



Ahmad Osama

Like us on FaceBook Join the fastest growing SQL Server group on FaceBook

Follow me on TwitterFollow me on FaceBook