SQL Server create User-Defined Table Types with schema not working properly -
i'm creating user-defined table types on sql server 2008r2/2012 statement:
create type [myschemaname].[myusertabletype] table ( [id] varchar(20) not null );
this works intended.
i got stored procedure deletes associated object given schema. user-defined table types not working properly. expecting types created associated schema.
if try drop schema, complain schema associated user-defined table type. hence not deleted.
but if query objects in db type_table tells me table types not belong schema. belong schema 'sys'
select name, schema_id, type_desc [testdb].sys.objects type_desc = 'type_table'; select * sys.schemas;
any idea why?
here screenshot output
instead of looking in sys.objects
these should in sys.types
or sys.table_types
(which additionally exposes type_table_object_id
).
select name, schema_id /*will "test" schema id*/ sys.types is_table_type = 1 , name = 'myusertabletype'
when create user defined type adds row sys.sysscalartypes
user supplied schema , name , row sys.sysschobjs
system generated name in sys
schema. system generated name created concatenating tt_
+ friendlyname + _
+ hex version of object id.
the 2 entities related via sys.syssingleobjrefs
/*this query works via dac*/ select so.id object_id, st.id user_type_id, * sys.sysschobjs join sys.syssingleobjrefs sor on sor.indepid = so.id join sys.sysscalartypes st on st.id = sor.depid st.name = 'myusertabletype'
Comments
Post a Comment