samaspin
samaspin

Reputation: 2402

Adding CLR UDF to SQL Server Database Project in Visual Studio 2010

I've created a new database project to group together all my useful stored procedures and functions so they can be easily deployed to any of my servers.

I'd like to add a couple of CLR UDFs. I tried adding a CLR project to my solution but this wants to be given a specific database to deploy to which is in conflict with the rest of the solution as the point is I want to be able to deploy anywhere!

Am i missing something?!

Sam : )

Upvotes: 1

Views: 1244

Answers (2)

samaspin
samaspin

Reputation: 2402

The solution was this...

  • Create a SQL Server 2005/2008 Database Project (inluding a new solution)
  • Add a SQL CLR database project to the solution but click cancel when it asks for a database
  • Add a reference to your CLR project from your main database project
  • Uncheck the deployment option on the CLR project

That was it, now when I deploy my database project it includes the CLR functions wherever I choose to deploy it.

Luckily some guy had documented the whole process so go check it out here

Upvotes: 1

Matt
Matt

Reputation: 1574

We added a normal class library to our solution, containing a class with static methods for our UDFs.

eg:

[SqlFunction(IsDeterministic = true, IsPrecise = true)]   
public static bool MyMethod(string x)
{
    ...
}

Then add a reference to this project from the database project.

Upvotes: 0

Related Questions