Reference columns in temp table

  • Hi,

    I have a stored procedure which produces a temp table using 'select into...'.

    Later in the sp I have 'UPDATE ##TMP SET Col1=@MyVar...'

    This procedure compiles and run fine in one database. When I try to create it in another database, I get the error:

    ---------------------

    Server: Msg 207, Level 16, State 1, Procedure MyProc, Line 71

    Invalid column name 'Col1'.

    Server: Msg 213, Level 16, State 1, Procedure MyProc, Line 72

    Insert Error: Column name or number of supplied values does not match table definition.

    ---------------------

    My question is: Is it some database settings I have missed out on?

    Thanks in advance!

    /Minh

  • Hi again,

    Some clarifications,

    1) The two databases in question are identical, at least on object level. I have confirmed this running a database compare in Power Designer.

    2) Since 1) is true, then the invalid column name error is not correct since that column does exist in the table where ##TMP has been created from

    /Minh

  • Hi once again,

    I overlooked the simplest step before viewing other possibilities. That is of course to run DBCC CHECKDB.

    After that the procedure could be created without problem.

    /Minh

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply