views:

294

answers:

2

I normally use the following code in SQL Server:

IF  EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[dbo].[proc_MyProc]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[proc_MyProc]
GO

How do I do this in SQL Azure? I get an error message: "Invalid object name 'sysobjects'."

Added:

The error was in fact in the checking if the stored procedure existed and have found code to do this:

IF  EXISTS (SELECT Routine_Name from information_schema.Routines WHERE Routine_Name = 'proc_MyProc')
DROP PROCEDURE [proc_MyProc]
GO
A: 

I have updated the question and provided the answer.

Mark Redman
A: 

This also works in SQL Azure

if object_id('[dbo].[proc_MyProc]') is not null
  DROP PROCEDURE [proc_MyProc]
Kyriacos