CLR Table Valued Function - Verify Steps to Create
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 ) AS
EXTERNAL 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 i开发者_运维知识库n 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 SAFE
permissions you can omit WITH PERMISSION_SET = SAFE
.
精彩评论