I have a weird problem. I’m trying to drop a procedure only if it exists, and have this code:
IF OBJECT_ID(N'dbo.CreateBlogUser', N'U') IS NOT NULL
DROP PROCEDURE CreateBlogUser;
PRINT 'IS NOT NULL'
GO
(the print is only there to try if it is true or not).
And when I run it, “IS NOT NULL” is printed, but the procedure isn’t dropped! It still exists in the database, so when I run my Create procedure, it fails.
However! When I tried to remove the NOT from the code, it works! The procedure is dropped and “IS NOT NULL” is still printed. This seems totally backwards and I don’t know why it does this. Is is something to do with the extra N:s and U:s in the OBJECT_ID? Found the code here
Replace ‘U’ on ‘P’