Tutorial by Examples

CLR procedures are not enabled by default. You need to run the following queries to enable CLR: sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'clr enabled', 1; GO RECONFIGURE; GO In addition, if some CLR module need external access, you should set TRUSTWORTHY pr...
Procedures, functions, triggers, and types written in .Net languages are stored in .dll files. Once you create .dll file containing CLR procedures you should import it into SQL Server: CREATE ASSEMBLY MyLibrary FROM 'C:\lib\MyStoredProcedures.dll' WITH PERMISSION_SET = EXTERNAL_ACCESS PERM...
If you have created .Net function, compiled it into .dll, and imported it into SQL server as an assembly, you can create user-defined function that references function in that assembly: CREATE FUNCTION dbo.TextCompress(@input nvarchar(max)) RETURNS varbinary(max) AS EXTERNAL NAME MyLibrary.[Nam...
If you have create .Net class that represents some user-defined type, compiled it into .dll, and imported it into SQL server as an assembly, you can create user-defined function that references this class: CREATE TYPE dbo.Point EXTERNAL NAME MyLibrary.[Name.Space.Point] You need to specify name...
If you have created .Net method in some class, compiled it into .dll, and imported it into SQL server as an assembly, you can create user-defined stored procedure that references method in that assembly: CREATE PROCEDURE dbo.DoSomethng(@input nvarchar(max)) AS EXTERNAL NAME MyLibrary.[Name.Space....

Page 1 of 1