title: Incorrect syntax near 'ON'
body: <pre><code>IF ( NOT EXISTS (SELECT * 
                   FROM INFORMATION_SCHEMA.TABLES 
                   WHERE TABLE_SCHEMA = 'dbo' 
                   AND  TABLE_NAME = 'OeeQualityDefects'))
  
   BEGIN
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      CREATE TABLE [dbo].[OeeQualityDefects](
      [CharID] [int] NOT NULL,
      [QualityCharID] [int] NULL
      ) ON [PRIMARY]
  END
  </code></pre>
  
  <p>Here I am trying to put a condition if the table is already exist in database if it is not there I suppose to create a table </p>
  
  <p>But, if I run this query I am getting errors</p>
  
  <blockquote>
    <p>Incorrect syntax near 'ON'.</p>
    
    <p>Incorrect syntax near 'END'.</p>
  </blockquote>