Thanks sal, I appreciate your comment and understand that may be the case. My problem wasn't with why the second test was performed, rather why the two tests are different.
Perhaps I didn't phrase the original question well, so let me try again.
In the first test to see if the SPROC exists it uses the "If Exists" test.
If the SPROC is found and an attempt to delete it is made, the OBJECT_ID() function test is used to see if it still exists after the attempted deletion.
I was wondering why the two tests to see if the SPROC exists are different (especially as the OBJECT_ID function is actually used in the sub query of the "If Exists" test). Couldn't the check of OBJECT_ID('dbo.SPROC_NAME') returning NULL have been used for both tests, or am I missing something obvious here?
There are a number of scripts that use this same syntax in a few places, so it isn't a one off.
Putting it another way, are the results of
Code:
IF EXISTS (select * from syscomments where id = object_id ('dbo.SPROC_NAME'))
and
Code:
IF OBJECT_ID('dbo.SPROC_NAME') IS NOT NULL
likely to be different? And, if they aren't, which is to be preferred and why? Thanks.