Skip to content

Just say no to CLR UDTs

Alex Papadimoulis is pretty adamant about not using CLR UDTs in SQL Server 2005.

No one has asked me that question just yet [“When Should I Use SQL-Server CLR User Definied Types (UDT)?”], but with the release of SQL Server 2005 just around the corner, I’m sure a handful of people will. Unlike regular User Defined Types, CLR UDTs are a new feature of SQL Server 2005 that allows one to create a .NET class and use it as a column datatype. As long as a few requirements are followed, one can create any class with any number of properties and methods and use that class as a CLR UDT.

Generally, when a new feature is introduced with a product, it can be a bit of a challenge to know when and how to use that feature. Fortunately, with SQL Server’s CLR UDTs, knowing when to use them is pretty clear:

Never.

Let me repeat that. Never. You should never use SQL Server CLR User Defined Types. I’m pretty sure that this answer will just lead to more questions, so allow me to answer a few follow-up questions I’d anticipate.

The full article can be read here. Another reason to take a pass on CLR UDTs is that it ties your database to SQL Server 2005. If you are doing an app that can run on SQL Server 2000, you just shot yourself in the foot.

Another reason to avoid CLR UDTs? Eliminating error messages like “File or assembly name udtname, Version=1.2.0.0, Culture=neutral, PublicKeyToken=389619d4c1235f8a, or one of its dependencies, was not found.”