User Defined TYPE between Databases

I have a database that contains common functions that I use in several databases. One of these functions takes in the table as a parameter, which is determined by the user TYPE. I would like to know if there is a way to call this function from another database.

I tried to determine the type in another database as follows:

DECLARE @bits as Common.dbo.Bits 

However I got the error too many prefixes

I tried adding TYPE to each database, and then passing the table of this type of function to the general database, but there I get an error

Operand type collision: bits are incompatible with bits

+7
source share
2 answers

You can not. Even if you declare a type the same way in two databases, they are not processed the same way. And in the DECLARE statement, only the schema name and the object name are allowed, so there is no way to refer to a type from another database.

See also this question for some possible work (if you control the databases involved)

+6
source

According to Creating Custom Data Types :

If a custom data type is created in the model database, this exists in all new user databases. However, if a data type is created in a user database, the data type exists only in that user database.

+5
source

All Articles