create database demo1
go

use demo1
go

drop table readings
drop function FahrenheitToCentigrade
drop function KilogramsToPounds
drop assembly MetricConverter
go

-- create the assembly
CREATE ASSEMBLY MetricConverter
FROM 'c:\types\metricconverter.dll'
go

create function FahrenheitToCentigrade (@a float)
returns float
with returns null on null input
external name MetricConverter.[MetricFunctions.MetricConverter].FahrenheitToCentigrade
go

-- use it
declare @x float
declare @y float
set @x = 10
set @y = dbo.FahrenheitToCentigrade(@x)
print @y
go

-- use it with NULL input
declare @x float
declare @y float
set @x = NULL
set @y = dbo.FahrenheitToCentigrade(@x)
if @y is null print 'NULL'
print @y
go

drop table readings
drop function FahrenheitToCentigrade
drop function KilogramsToPounds
drop assembly MetricConverter
go

-- create the assembly
CREATE ASSEMBLY MetricConverter
FROM 'c:\types\metricconverter.dll'
go

create function FahrenheitToCentigrade (@a float)
returns float
-- with returns null on null input
external name MetricConverter.[MetricFunctions.MetricConverter].FahrenheitToCentigrade
go

drop function FahrenheitToCentigrade
drop function KilogramsToPounds
drop assembly MetricConverter
go

-- create the assembly
CREATE ASSEMBLY MetricConverter
FROM 'c:\types\metricconverter.dll'
go

create function FahrenheitToCentigradeDec (@a decimal)
returns decimal
with returns null on null input
external name MetricConverter.[MetricFunctions.MetricConverter].FahrenheitToCentigrade
go
