I have some check constraints that call CLR functions. Functions like 'CheckMailingAddress' and 'CheckPassword' just accept an nvarchar(4000) parameter, run the parameter through a Regex, and return true if it matchs and false if it doesn't.
Some of my functions are working fine. They used to all work fine, and nothing has really changed, except all my database fields are nvarchar instead of varchar now (I added Unicode support).
I cannot see any reason why the CheckMailingAddress function fails, but the other functions succeed. When I run CheckMailingAddress in a standalone app, it works just fine. When it runs inside SQL Server, I get the message 'A .NET Framework error
occurred during execution of user-defined routine or aggregate: "CheckMailingAddress": .', and as you can see there is no error message. Just a space where there should be one, followed by a period. I cannot explain this.
Compiling in Visual Studio 2010 and running on SQL Server 2008.
I noticed that it's only failing on functions that were built to accept null values (in the case where "allow_null" is true in the code below). The check functions are auto-generated from custom attributes on the class in the C# code, and the MSIL
is slightly different if the attribute indicates that the database
View Complete Post