Tutorial by Examples

Normally you would want to avoid using cursors as they can have negative impacts on performance. However in some special cases you may need to loop through your data record by record and perform some action. DECLARE @orderId AS INT -- here we are creating our cursor, as a local cursor and only a...
A simple cursor syntax, operating on a few example test rows: /* Prepare test data */ DECLARE @test_table TABLE ( Id INT, Val VARCHAR(100) ); INSERT INTO @test_table(Id, Val) VALUES (1, 'Foo'), (2, 'Bar'), (3, 'Baz'); /* Test data prepared */ /* Iterator variabl...

Page 1 of 1