1

I'm testing out some SQL CLR stuff in VS 2008 and SQL Server 2005, how do I install a user defined function on the database? I built it and have the DLL, but now what?

3
  • 1
    You would use CREATE ASSEMBLY. One of the first Google hits: msdn.microsoft.com/en-us/library/ms254956(v=vs.90).aspx Commented Sep 25, 2012 at 1:02
  • oh okay so create assembly is for that too, thanks! Commented Sep 25, 2012 at 1:03
  • 1
    And then CREATE FUNCTION ... EXTERNAL NAME (that example uses a procedure but the syntax is the same). Commented Sep 25, 2012 at 1:03

1 Answer 1

2

You would use CREATE ASSEMBLY. e.g.:

CREATE ASSEMBLY MyAssembly FROM 'C:\path\fille.dll' WITH PERMISSION_SET = SAFE;
GO

And then optional syntax for CREATE FUNCTION that references the function in your assembly (the external name will be dependent on how you structured your code):

CREATE FUNCTION dbo.MyFunction(@param <data_type>)
RETURNS <data_type>
AS EXTERNAL NAME MyAssembly.SqlServerFunctions.FunctionName;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.