Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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