Instead of looking in sys.objects
for these you should look in sys.types
or sys.table_types
(which additionally exposes the type_table_object_id
).
SELECT name,
schema_id /*Will be the "test" schema id*/
FROM sys.types
WHERE is_table_type = 1
AND name = 'MyUserTableType'
When you create a user defined type it adds a row to sys.sysscalartypes
with the user supplied schema and name and a row to sys.sysschobjs
with a system generated name in the sys
schema. The system generated name is created by concatenating TT_
+ FriendlyName + _
+ Hex version of object id.
The two entities are related together via sys.syssingleobjrefs
/*This query only works via the DAC*/
SELECT so.id AS object_id,
st.id AS user_type_id,
*
FROM sys.sysschobjs so
JOIN sys.syssingleobjrefs sor
ON sor.indepid = so.id
JOIN sys.sysscalartypes st
ON st.id = sor.depid
WHERE st.name = 'MyUserTableType'