I had a chance to play around with this new feature in SQL 2005 the other day. After reading a few articles here is the quick and dirty on how to implement.
A quick and dirty guide as to when is the best time to use:
http://www.developer.com/net/net/article.php/3528601
How to add:
1) Create a Class project in Visual Studio
2) Create a new class and cut and paste the following code:
using System;
using System.Collections.Generic;
using System.Text;
namespace SampleCLR
{
public class CLRTestClass
{
public static string Freak(string name)
{
return name.ToString() + " Is a FREAK!!!";
}
}
}
3) Compile.
4) Next
Register the assembly (in SQL 2005) by right clicking ‘Assemblies’ > ‘New Assembly’ under Programmability.
5) Run these scripts:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION dbo.clrWhosFreak( @name as nvarchar(200) ) RETURNS nvarchar(4000) AS EXTERNAL NAME [SampleCLR].[SampleCLR.CLRTestClass].[Freak]
sp_configure 'clr enabled', 1
go
reconfigure
go
6) Then open a query window and run….
select dbo.clrWhosFreak('Steve')
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5