BUG: Stored Procedure with SELECT INTO May Fail with Error 207Last reviewed: April 29, 1997Article ID: Q113346  | 
	
	
The information in this article applies to:
 - Microsoft SQL Server version 4.2 for OS/2BUG# OS/2: 1829 (4.2) 
 SYMPTOMSExecution of a stored procedure which creates some temporary tables using SELECT INTO and references a column in one of the newly created temporary tables may fail with an error message 207: 
 Invalid column NameNOTE: The conditions under which the above error occurs is described in the More Information section at the end of this article. 
 WORKAROUNDBreak the SELECT INTO statement into two statements: a CREATE TABLE and a INSERT INTO: Example: 
    select 'NEW_COLUMN'=COL1
       into #temp2
       from #temp1
can be broken into
 create table #temp2 (NEW_COLUMN float) insert into #temp2 select COL1 from #temp1 STATUSMicrosoft has confirmed this to be a problem in SQL Server version 4.2 for OS/2. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available. 
 MORE INFORMATIONThe following are the condition that will produce the error: For example: 
    create procedure PROC1
       as
       select *
       into #temp1
       FROM MYTABLE
       select 'NEW_COLUMN' = COL1
       into #temp2
       from #temp1
       select NEW_COLUMN from #temp2
The above stored procedure may sometimes fails with the error message:
 Msg 207, Level 16, State 2: Invalid column name 'NEW_COLUMN'when the following conditions are satisfied: 
  | 
	
	Additional query words: temp 
 © 1998 Microsoft Corporation. All rights reserved. Terms of Use.  |