title: DROP PROCEDURE IF EXISTS <SPName/TableName> is not working
body: <p>I have generated the stored procedure with SQL Server Management Studio 2016 v13.0.16. After generated script, I have executed the script and I'm getting an error:</p>
  
  <blockquote>
    <p>Incorrect syntax near the keyword 'IF</p>
  </blockquote>
  
  <p>The error occurs at line: </p>
  
  <pre><code>DROP PROCEDURE IF EXISTS [dbo].[SP_Test]
  </code></pre>
  
  <p>I have checked the SQL Server version: </p>
  
  <pre><code>select @@version 
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>Microsoft SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64)   
  Aug 15 2017 10:23:29   
  Copyright (c) Microsoft Corporation  Express Edition (64-bit) on Windows NT 6.3 &lt;X64&gt; (Build 14393: ).
  </code></pre>
  
  <p>Generated script as: </p>
  
  <pre><code>DROP PROCEDURE IF EXISTS [dbo].[SP_Test]
  Incorrect syntax near the keyword 'IF'.
  /****** Object:  StoredProcedure [dbo].[SP_Test]    Script Date: 02/24/2020 12:28:17 PM ******/
  DROP PROCEDURE IF EXISTS [dbo].[SP_Test]
  GO
  /****** Object:  StoredProcedure [dbo].[SP_Test]    Script Date: 02/24/2020 12:28:17 PM ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SP_Test]') AND type in (N'P', N'PC'))
  BEGIN
  EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[SP_Test] AS'
  END
  GO
  -- =============================================
  -- Author: &lt;Author,,Name&gt;
  -- Create date: &lt;Create Date,,&gt;
  -- Description: &lt;Description,,&gt;
  -- =============================================
  ALTER PROCEDURE [dbo].[SP_Test]
  AS
  BEGIN
  select * from Emp
  END
  GO
  </code></pre>
  
  <p>Does anyone help me?</p>