Created
March 1, 2016 09:43
-
-
Save radityopw/2f25ef61e069514ee255 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
use tempdb | |
go | |
-- membuat functions | |
CREATE FUNCTION dbo.salesOrderTerakhir(@nilai_terakhir int = 5) | |
returns table | |
as | |
return ( | |
select * from ( | |
select row_number() over (order by salesOrderId Desc ) as nomor, * | |
from AdventureWorks2012.sales.SalesOrderHeader | |
) a where nomor <= @nilai_terakhir | |
); | |
go | |
-- menjalankan stored procedure dan melihat hasilnya | |
select * from dbo.salesOrderTerakhir(10) | |
-- menghapus | |
DROP function [dbo].[salesOrderTerakhir] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment