Hi,
I am using the following code to check if the temp table exists and drop the table if it exists before creating again. It works fine as long as I don't change the columns. If I add a column later, it will give error saying "invalid column". Please let me know what I am doing wrong.
IF OBJECT_ID('tempdb..#Results') IS NOT NULL DROP TABLE #Results
CREATE TABLE #Results ( Company CHAR(3), StepId TINYINT, FieldId TINYINT, )
select company, stepid, fieldid from #Results
If I run the above code, it works fine. Now let's say I add a column fieldname and use that field in the select statement, it gives error.
Thanks, sridhar.