I have a set of custom CLR functions installed in single database. When I need to use these functions in queries/views/procedures on another database, I simply reference them by three-part name [db].[schema].[function]()
and it works fine.
But I can't use them in computed columns because of error 4120
A user-defined function name cannot be prefixed with a database name in this context
.
Ofcourse, there's no problem with adding computed column on the same database using two-part name [schema].[function]()
.
Any ideas how to solve this problem? Maybe I can create some kind of "shortcut" functions in every other database that would reference "original" ones? Or could I install these functions in one of system databases in a way that will enable me to call function using only it's name, just like left()
or substring()
?
For now, the script that I use to update and install new functions, does the same thing on every database that I need the functions in, and in model
db, too. But I wish there was more elegant way to do this.