Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
set nocount on
use AdventureWorks2012
declare @total int
declare @iterator int
declare @table table (nomor int,id int)
declare @temp_id int
declare @value_temp money
set @iterator = 1
set @total = 10
insert into @table
select row_number() over( order by salesOrderId desc) as nomor,salesorderid
from (
select top 10 salesOrderId
from sales.SalesOrderHeader
order by SalesOrderID desc
) a
while(@iterator <= @total)
print 'ini proses ke ' + cast(@iterator as varchar) + '/' + cast(@total as varchar)
select @temp_id = id from @table where nomor = @iterator
print 'nilai temp id = '+cast(@temp_id as varchar)
select @value_temp = TotalDue from sales.SalesOrderHeader where SalesOrderID = @temp_id
print 'total : '+ cast(@value_temp as varchar)
set @iterator = @iterator + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment