Skip to content

Instantly share code, notes, and snippets.

@radityopw
Created March 1, 2016 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radityopw/711545dd7c00e9a15492 to your computer and use it in GitHub Desktop.
Save radityopw/711545dd7c00e9a15492 to your computer and use it in GitHub Desktop.
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