Check if type exists in MSSQL

Adam K Dean - Mar 27 '14 - - Dev Community

Snippet time. Check if a type exists in MSSQL with the following simple query:

IF TYPE_ID(N'[dbo].[udt_SomeCustomType]') IS NOT NULL
BEGIN
    -- type exists, do something here
END
Enter fullscreen mode Exit fullscreen mode

And of course, the other way round:

IF TYPE_ID(N'[dbo].[udt_SomeCustomType]') IS NULL
BEGIN
    -- type does not exist, do something here
END
Enter fullscreen mode Exit fullscreen mode

More SQL snippets to come.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player