title: If condition to determine which stored procedures to create
body: <p>This is more than just checking for existence</p>
  
  <p>I have a script that creates 27 stored procedures.  I need to run this script against two databases.  The second database only needs 25 of the 27 stored procedures.  I was hoping to wrap my code in an if statement to determine the current db </p>
  
  <p>Pseudo Example:</p>
  
  <pre><code>DROP PROCEDURE IF EXISTS [A]
  GO
  
  CREATE PROCEDURE [dbo].[A]
      @CountryCode CHAR(3),
      @LanguageCode CHAR(3) = NULL,   
  AS
  BEGIN
  ...
  
  GO
  
  IF (DB_NAME() &lt;&gt; 'DB2')
  BEGIN
      DROP PROCEDURE IF EXISTS [B]
      GO
  
      CREATE PROCEDURE [dbo].[B]
          @CountryCode CHAR(3),
          @LanguageCode CHAR(3) = NULL,   
      AS
      BEGIN
      ...
  
      GO
  
      DROP PROCEDURE IF EXISTS [C]
      GO
  
      CREATE PROCEDURE [dbo].[C]
          @CountryCode CHAR(3),
          @LanguageCode CHAR(3) = NULL,   
      AS
      BEGIN
      ...
      GO
  END
  </code></pre>
  
  <p>I know I can wrap it in an <code>EXEC</code> for scope but at that point I might as well create a new file.  I have seen the older questions, but I didn't know if there was anything new in SQL Server 2016/2019 to address this.</p>