Thank you for the reply. The GO if placed after the second IF..DROP works. So if I have IF OBJECT_ID('tempdb..#A') IS NOT NULL DROP TABLE #A; CREATE TABLE #A (C1 INT); INSERT INTO #A (C1) VALUES(1); SELECT * FROM #A; GO IF OBJECT_ID('tempdb..#A') IS NOT NULL DROP TABLE #A; CREATE TABLE #A (C2 INT); SELECT * FROM #A;
This will work and show C2 as the column name. However if I have:IF OBJECT_ID('tempdb..#A') IS NOT NULL DROP TABLE #A; CREATE TABLE #A (C1 INT); INSERT INTO #A (C1) VALUES(1); SELECT * FROM #A; GO IF OBJECT_ID('tempdb..#A') IS NOT NULL DROP TABLE #A; CREATE TABLE #A (C2 INT); SELECT * FROM #A; INSERT INTO #A (C2) VALUES(2);
It fails on the insert.I can add the GO but this will not work in a stored procedure.djj