CREATE TABLE #temp1 (xyz char(1)) EXEC SP2 SELECT * FROM #temp1Now, SP2 contains code that uses #temp1 if it exists:
IF OBJECT_ID('TempDb..#temp1) IS NOT NULL INSERT INTO #temp1 (xyz) VALUE ('x') ELSE SELECT xyz FROM someothertableWhat ends up happening is that SP2 does not recognize that #temp1 has already been created and what we're trying to figure out is why. Something to do possibly with *where* Temp tables get created? Isn't it *always* in TempDb? If not, then where is the setting that dictates that?