title: Drop and re-create procedure if it exists in T-SQL not working
body: <pre><code>IF EXISTS ( SELECT  * FROM    sys.objects WHERE   object_id = OBJECT_ID(N'LOCATION') AND type IN (N'P', N'PC')) 
  DROP PROCEDURE [dbo].[LOCATION]
  GO
  
  CREATE PROCEDURE [dbo].[LOCATION]
      @IP NVARCHAR(100)
  AS
  BEGIN
  DECLARE @IPNumber BIGINT
  
  SELECT @IPNumber = dbo.ConvertIp2Num(@IP)
  
      SELECT [country_code],[country_name]
      FROM [myDatabase].[dbo].[CountryIP]
      WHERE @IPNumber BETWEEN ip_from AND ip_to
  END
  </code></pre>
  
  <p>I have the above code to check if stored procedure LOCATION exists in the current database. I expect it to drop and re-create the procedure if it exists.</p>
  
  <p>However, if the procedure exists the code is still executing and as a result i get the following error 'There is already an object named 'LOCATION' in the database.'</p>
  
  <p>Why is that code failing to drop the procedure if it exists?</p>
  
  <p>The same code works properly for a another procedure in the same database.</p>