USE adventureworks
GO

-- create the assembly
CREATE ASSEMBLY TempFunctions
FROM 'c:\types\tempfunctions.dll'
GO

SELECT * FROM sys.assemblies 
GO 
SELECT * FROM sys.assembly_files 
GO 
SELECT * FROM sys.assembly_references 
GO 

--try to create a function FROM MetricConverter
CREATE FUNCTION KilogramsToPounds (@a float)
returns float
external name MetricConverter.[MetricFunctions.MetricConverter].KilogramsToPounds
GO

-- drop the assembly
-- this drops invisible dependents
DROP ASSEMBLY TempFunctions
GO


--alter metricconverter to make it visible
ALTER ASSEMBLY MetricConverter
WITH VISIBILITY = ON

--GO back and retry creating the function
CREATE FUNCTION KilogramsToPounds (@a float)
returns float
external name MetricConverter.[MetricFunctions.MetricConverter].KilogramsToPounds
GO

