I’ve created my first CLR table valued function. The steps I went through were:
- Create Library
- Run this command – EXEC dbo.sp_configure ‘clr enabled’,1 RECONFIGURE
- Copy the dll from step 1 to c: drive for convenience
- Create the assembly with dll- create assembly from ‘c:\’ WITH PERMISSION_SET = SAFE
-
Create function –
CREATE FUNCTION MyFunction(@input nvarchar(max))
RETURNS Table(
— columns
)
ASEXTERNAL NAME
[Assembly Name Here]. [Class Name Here] . [Static Function In Class Here]
I recall reading something where I had to also copy the dll into the binn directory below MSSQL.
My questions are:
- Do I need to copy the dll to the Binn directory in MSSQL
- Do the steps
above look correct?
You don’t need to copy dll; once the library is loaded, you don’t need the external file.
Your steps look good to me, but you might want to add “Testing deployed function” to your steps.
Also, for
SAFEpermissions you can omitWITH PERMISSION_SET = SAFE.