Instantly share code, notes, and snippets.

Embed
What would you like to do?
use tempdb
go
-- membuat functions
CREATE FUNCTION dbo.minimum(@nilai1 float, @nilai2 float)
returns float
as
begin
declare @min float
set @min = @nilai1
if @nilai2 < @nilai1
begin
set @min = @nilai2
end
return @min
end
go
-- menjalankan stored procedure dan melihat hasilnya
select SalesOrderID,SubTotal,Freight, dbo.minimum(subtotal,freight) as min_nilai from AdventureWorks2012.sales.SalesOrderHeader
-- menghapus
DROP function [dbo].[minimum]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment