I've seen on sys.table_types
that I have 8 user-defined table types on my db.
How can I check if there is any table (1000+) on my db that are currently using any of these user-defined table types before dropping them.
sql server
I've seen on sys.table_types
that I have 8 user-defined table types on my db.
How can I check if there is any table (1000+) on my db that are currently using any of these user-defined table types before dropping them.
Best Answer
First things first
Source
This means that table types can be used by
table variables
/TVP
's and these can be used in parameter calls. An example of this is a stored procedure calling aTVP
.Table types are not permanent tables or used by permanent tables.
sys.parameter_type_usages
You can use the
sys.parameter_type_usages
dmv to get the parameters that are mapped to user defined types, these includeTable Valued Parameters
.Source
Testing
test statements from here
Running the query at the top gives us both the procedure & the table type used
The call to the procedure simply uses the table type and a self defined table variable:
Statements also from here