Skip to content

Instantly share code, notes, and snippets.

@radityopw
Created March 1, 2016 09:22
Show Gist options
  • Save radityopw/a5de78c2b747282b0b84 to your computer and use it in GitHub Desktop.
Save radityopw/a5de78c2b747282b0b84 to your computer and use it in GitHub Desktop.
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