I have a user-defined table type. I want to check it's existence before editing in a patch using OBJECT_ID(name, type)
function.
What type
from the enumeration should be passed for user-defined table types?
N'U'
like for user defined table doesn't work, i.e. IF OBJECT_ID(N'MyType', N'U') IS NOT NULL
5条答案
按热度按时间bwntbbo31#
You can look in sys.types or use TYPE_ID:
Just a precaution: using type_id won't verify that the type is a table type--just that a type by that name exists. Otherwise gbn's query is probably better.
ffvjumwh2#
sys.types ... they aren't in sys.objects under their normal name
Update, Mar 2013
You can use TYPE_ID too
i5desfxk3#
nwsw7zdq4#
Following examples work for me, please note "is_user_defined" NOT "is_table_type"
hgc7kmma5#
You can use also system table_types view