Instantly share code, notes, and snippets.

Embed
What would you like to do?
set nocount on
use AdventureWorks2012
go
declare @total money
declare @cursor CURSOR
set @cursor = cursor for
select top 10 TotalDue
from sales.SalesOrderHeader
order by SalesOrderID desc
open @cursor
fetch next from @cursor into @total
while @@FETCH_STATUS = 0
begin
print 'total :'+cast(@total as varchar)
fetch next from @cursor into @total
end
close @cursor
deallocate @cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment