I usually do it like this, because it's shorter to code.if objectproperty(object_id(N'dbo.spAddNewStudent'),N'IsProcedure') = 1 drop procedure dbo.spAddNewStudent
It works fine for tables and other objects also. You just have to pick the correct object property.For a table:if objectproperty(object_id(N'dbo.MyTable'),N'IsUserTable') = 1 drop table dbo.MyTable
For a scalar function:if objectproperty(object_id('dbo.F_MY_FUNCTION'),'IsScalarFunction') = 1 begin drop function dbo.F_MY_FUNCTION endCODO ERGO SUM