I am using a Visual Studio 2012 Database project with a CLR UDF (below). For some reason, after deploying it to the database, I call the function and I get the type name returned instead of the expected result.
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlChars FlattenText(SqlChars text)
{
return new SqlChars(Regex.Replace(text.ToString(), @"\s+", " ", RegexOptions.Multiline));
}
}
When I call it like this:
SELECT TOP 1 dbo.FlattenText(MyColumn) AS MyResult FROM MyTable
Here is what I get returned:
System.Data.SqlTypes.SqlChars