Skip to content

Instantly share code, notes, and snippets.

Created Mar 1, 2016
What would you like to do?
use tempdb
-- membuat functions
CREATE FUNCTION dbo.salesOrderTerakhir(@nilai_terakhir int = 5)
returns table
return (
select * from (
select row_number() over (order by salesOrderId Desc ) as nomor, *
from AdventureWorks2012.sales.SalesOrderHeader
) a where nomor <= @nilai_terakhir
-- 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