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
You can look in sys.types or use TYPE_ID:
IF TYPE_ID(N'MyType') IS NULL ...
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.