пятница, 29 октября 2010 г.

Enable CLR Integration in MS SQL Server

This tip can be useless especially in 2010 years, because developers can use SQL CLR during 5+ years and they have already known this procedure, so this tip is more for me, because every time I start using SQL CLR I search for clear script that enables this feature in MS SQL Server 2005/2008.
By default this feature is disabled in effort to security and some performance. Next code will solve this issue:
EXEC sp_configure 'show advanced options' , '1'
GO
reconfigure
GO
EXEC sp_configure 'clr enabled' , '1'
GO
reconfigure
-- turn back advanced options
EXEC sp_configure 'show advanced options' , '0'
GO
After we can write any user-defined functions aggregates, stored procedures, etc...using high versatile and flexible .NET Framework infrastructure in C# or VB.NET.

Typically, I use this feature to accomplish goals of adding Regular Expression support in MS SQL Server. Useful article CLR Assembly RegEx Functions for SQL Server by Example is written by @Phil_Factor.
That's all for today. If you don't mind my dear reader, I will post short tips for myself from time to time, maybe you also find them useful in some cases.