Adam K Dean

Check if type exists in MSSQL

Published on 27 March 2014 at 16:07 by Adam

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

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

More SQL snippets to come.



This post was first published on 27 March 2014 at 16:07. It was filed under archive with tags sql, mssql, snippet.