If I have a user table type (like CREATE TYPE ...
), how do I get to it's definition in the system tables?
I know I can see it through SSMS through GUI, but I would like to have a query to retrieve it from system tables.
I don't see it through any of the modules:
SELECT
*
FROM
sys.all_sql_modules m
WHERE
m.definition like 'CREATE TYPE %' --doesn't output any types definitions
Best Answer
You need to query
sys.table_types
:Make sure you are connected to the proper database.
If you want a
CREATE TYPE
statement like the one from SSMS, you will have to build it from the results of the previous query. That or trace the SSMS's query to see how it builds it when you ask it from the GUI, but there's a chance it's very convoluted (although bulletproof).