SQL SERVER 2012 OBJECT_ID

Originally a stored procedure is executed correctly, the upgrade sqlserver prompted the temporary table already exists, find information sql server 2012 OBJECT_ID ( 'temporary table') returns a value that is negative, and before the 2008r2 is positive, resulting in the following statement:

	IF (SELECT ISNULL(OBJECT_ID('TEMPDB..#XXXXXX'),0) ) >0 
	BEGIN   
		DROP TABLE TEMPDB.#XXXXXX
	END

  There is a problem, because it will not be a negative number greater than 0, but the temporary table actually exists, adjusted

	IF OBJECT_ID('TEMPDB..#XXXXXX') IS NOT NULL
	BEGIN   
		DROP TABLE TEMPDB.#XXXXXX
	END

  

Guess you like

Origin www.cnblogs.com/Wicher-lsl/p/11235658.html