'How does a "Schema changed after the target table was created" error occur?

I hit this error while my web application was trying to execute a SELECT INTO on a MSSQL 2005 database. I really have two questions:

  1. What does this error mean and how does this happen?
  2. Is there a way to prevent these errors by coding in a different way?


Solution 1:[1]

You can get this error if a database trigger(AFTER CREATE_TABLE) changes the table, when using SELECT INTO.

Solution 2:[2]

Also you can get this when you have the SELECT * INTO #TABLE FROM TABLE used within a stored procedure and it is run multiple times concurrently.

Solution 3:[3]

You have to specify dbo. as the schema for the first table.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Daniel Smolka
Solution 3 Phillip Senn