<p>I've recently discovered that it's possible to place .net assemblies on SQL Server >=2005 servers so that .net functions can be called in T/SQL statements.</p>

<p>I wondered what uses people found for these and how they perform?</p>

[{'answer_id': 39667, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 0, 'selected': False, 'text': '<p>I found it to be very useful.  </p>\n\n<p>I used this possibility to extend MSSQL2005 XML related functions.  </p>\n\n<p>If I remember correctly you can even introduce your own data types.</p>\n'}, {'answer_id': 39679, 'author': 'Eric Z Beard', 'author_id': 1219, 'author_profile': 'https://Stackoverflow.com/users/1219', 'pm_score': 0, 'selected': False, 'text': "<p>This is normally used if you need to interact with the operating system in some way, for example, to place a message in MSMQ or write to a file.  It is also useful if you have some complex mathematical or financial calculations that are already implemented in .NET, and you don't want to re-write them in T-SQL.</p>\n"}, {'answer_id': 39709, 'author': 'Oppositional', 'author_id': 2029, 'author_profile': 'https://Stackoverflow.com/users/2029', 'pm_score': 2, 'selected': False, 'text': '<p>The first general purpose use for the CLR in SQL 2005 I created was a SQL 2005 assembly that has a variety of functions that perform string operations and pattern matches using regular expressions. The native string functions in SQL 2005 can be augmented so that you can validate common formats like phone numbers or credit card numbers or perform ad-hoc regular expressions within stored procedures.</p>\n\n<p>For deterministic user defined functions, I have found the SQL CLR support to be very performant.</p>\n'}, {'answer_id': 39719, 'author': 'spoulson', 'author_id': 3347, 'author_profile': 'https://Stackoverflow.com/users/3347', 'pm_score': 0, 'selected': False, 'text': '<p>CLR integration with SQL 2005 is particularly useful for user-defined functions/stored procs written in .NET and also user-defined data types.  e.g. You could write a heavy duty data type that allows SQL to define objects and reference properties.  You could write some super-duper datetime variation, for instance.</p>\n'}, {'answer_id': 1145290, 'author': 'CMB', 'author_id': 136524, 'author_profile': 'https://Stackoverflow.com/users/136524', 'pm_score': 0, 'selected': False, 'text': '<p>Oppositional, I agree with you.   Assemblies are wonderful for all of those things that not at all attainable or barely attainable in T-SQL (via in hackish methods).</p>\n\n<p>Simplicity of use is the key.  Please be aware of the following implications... </p>\n\n<ol>\n<li>The use of an assembly introduces trust/security/permission configuration issues.</li>\n</ol>\n\n<p>An assembly will have to be defined into the database.  If the assembly is not signed, the database will have to allow UNTRUSTED code.  This database setting is reset when a database is detached/reattached.</p>\n\n<ol start="2">\n<li>The use of an assembly affects the SQL Server configuration  (not just a database).</li>\n</ol>\n\n<p>To run an assembly, you must first insure that SQL Server lightweight pooling is disabled.</p>\n\n<ol start="3">\n<li>For the Assemblies functions, remember to be conservative with data manipulations; especially, on busy tables.  </li>\n</ol>\n\n<p>If you can, avoid the use of an Assembly method that attempts to affect too many rows at a time. Take care for those used within table triggers..as some of these will degrade performance sharply.   </p>\n'}]
['https://Stackoverflow.com/questions/39661', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3394/']