views:

221

answers:

1

Can this be done? Or are all CLR UDTs in SQL Server just utilized in SQL Server?

+1  A: 

Yes. The UDT assemblies and all dependent assemblies have to be on the client already, accessible either in the application folder or on the GAC. Your project must reference the UDT assembly bytes, or it has to load the UDT at runtime prior to referencing the UDT type column. This MSDN link explains all the requirements your UDT has to meet before ADO.Net can instantiate them in your client. Needlses to say, your UDT code should not assume it runs in the SQL CLR runtime, ie. should not attempt to open a 'context' connection or anything SQL specific.

Remus Rusanu
Yup, exactly as Remus says. If you reference the assembly in the application and then package it with your distributable, it will work outside of SQL.
Jonathan Kehayias