title: T-SQL DROP TYPE IF EXISTS
body: <p>I'm currently working on a script in T-SQL in SQL Server 2014.</p>
  
  <p>I need to drop a user-defined table type, but only if it exists, and create it again after the delete/drop type.</p>
  
  <p>I did some research on the web and found a solution, which does, unfortunately, not work at all.</p>
  
  <p>My current script looks like this:</p>
  
  <pre><code>IF OBJECT_ID('MySchema.tProjectType', 'U') IS NOT NULL
          DROP TYPE [MySchema].[tProjectType];
  
  CREATE TYPE [MySchema].[tProjectType] AS TABLE
      (
          Id INT
          , IsPrivate BIT
          , IsPublic BIT
      );
  </code></pre>
  
  <p>My error message:</p>
  
  <blockquote>
    <p>The type 'MySchema.tProjectType' already exists, or you do not have permission to create it.</p>
  </blockquote>
  
  <p>Do you know how to successfully check if a user defined table type exists before I can delete it in SQL Server 2014?</p>