You get this error, because the UDF name is resolved from the scope of tempdb. This is why it works when Kalman tests - because he tested in tempdb.
Visakh suggested that you should add the database name, but that's not a good solution, because one day you may restore a copy of the database with a different name.
The correct solution is to - skip the constraint. To wit, having a UDF in a CHECK constraint is rarely a good idea, and a UDF that performs data access can be a real disaster for performance.
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
No comments:
Post a Comment