If I create a stored procedure in the master database, and I want to execute it from any of my databases I just follow this link:

Making a Procedure Available in all Databases

that give me this code example:

enter image description here

Just by following the example above, I can call my procedure from any database.

what about if I create a table data type in master, how can I use it in any of my databases?

use master

        IF NOT EXISTS (select * from sys.types where name = 'theReplicatedTables') 
                CREATE TYPE theReplicatedTables AS TABLE 
                (  OBJ_ID INT NOT NULL,
                  PRIMARY KEY CLUSTERED (OBJ_ID)

use APIA_Repl_Sub
declare @the_tables [dbo].[theReplicatedTables]

enter image description here

2 Answers 2


There is no way to do that with table types. You will need to replicate that in all databases. But, if you want this table type available while creating a new database, you can just add it in the model database. There are a couple restrictions to using table-valued parameters. You can't even use table-valued parameters across databases. Check some details here.


Types don't have the ability to cross database thresholds or to be marked as system. So you'll need to create that type in each database where you want to use it. (I'm not a big fan on relying on things like data or types in master, because they disappear when you move to a different system.)

For existing databases, you can just create the type in a loop. For new databases (through CREATE DATABASE), create the type in model.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.