August 29, 2003 at 1:52 pm
I have the following similar statement in a tsql procedure that errors out telling me that there already is a #tmp object in the database... if I read the TSQL correctly, the #TMP does not acctually get created on the ELSE statement if the 1=1 statement is true. So why the error? Thanks in advance....
IF 1= 1 BEGIN
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE ID = OBJECT_ID(N'tempdb..#tmp')) BEGIN
DROP TABLE #tmp
END
CREATE TABLE #tmp(tID INT IDENTITY (1,1) NOT NULL,Hcode VARCHAR(50))
END
ELSE BEGIN
IF EXISTS (SELECT * FROM tempdb.dbo.sysobjects WHERE ID = OBJECT_ID(N'tempdb..#tmp')) BEGIN
DROP TABLE #tmp
END
CREATE TABLE #tmp(tID INT IDENTITY (1,1) NOT NULL,Hcode VARCHAR(50))
END
-Francisco
-Francisco
August 29, 2003 at 5:27 pm
Found my solution here...
http://support.microsoft.com/default.aspx?scid=kb;en-us;295305
-Francisco
-Francisco
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply