Created
March 1, 2016 01:39
-
-
Save radityopw/b78a6e29ca6ca0ca6b38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocount on | |
use AdventureWorks2012 | |
go | |
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) | |
begin | |
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 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment