title: "Invalid column name" error when calling insert after table created
body: <p>I'm developing SQL script, using SSMS, which makes some changes in database:</p>
  
  <pre><code>USE MyDatabase;
  
  BEGIN TRANSACTION;
  
  -- some statements
  
  PRINT(N'#1');
  
  IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = N'dbo' AND TABLE_NAME = N'Table1' AND COLUMN_NAME = 'Table2_Id'))
  BEGIN
      ALTER TABLE [dbo].[Table1] DROP CONSTRAINT [FK_Table1_Table2_Table2_Id];
      ALTER TABLE [dbo].[Table1] DROP COLUMN [Table2_Id];
      DROP TABLE [dbo].[Table2];
  
      PRINT(N'Table2 was dropped.');
  END
  
  PRINT(N'#2');
  
  IF (NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = N'dbo' AND TABLE_NAME = N'Table2'))
  BEGIN
      CREATE TABLE [dbo].[Table2]
      (
          [Id] INT NOT NULL PRIMARY KEY IDENTITY,
          [Number] INT NOT NULL UNIQUE,
          [Name] NVARCHAR(200) NOT NULL,
          [RowVersion] TIMESTAMP NOT NULL
      );
  PRINT(N'Table2 was re-created.');
      INSERT INTO [dbo].[Table2]([Number], [Name]) VALUES(-1, N'Default value');
  PRINT(N'Default value was inserted in Table2.');
  END
  
  -- some statements
  
  COMMIT TRANSACTION;
  </code></pre>
  
  <p>If <code>Table1</code> has a column, named <code>Table2_Id</code>, then database has two tables (<code>Table1</code> and <code>Table2</code>) and a foreign key relationship between them. In that case, I need to:</p>
  
  <ul>
  <li>drop foreign key relationship <code>FK_Table1_Table2_Table2_Id</code>;</li>
  <li>drop foreign key column <code>Table1.Table2_Id</code>;</li>
  <li>drop <code>Table2</code>;</li>
  <li>re-create <code>Table2</code>, using new table schema;</li>
  <li>insert some default value in <code>Table2</code>.</li>
  </ul>
  
  <p>When I'm trying to execute this script, I'm getting these errors:</p>
  
  <blockquote>
    <p>Msg 207, Level 16, State 1, Line 262 Invalid column name 'Number'.<br>
    Msg 207, Level 16, State 1, Line 262 Invalid column name 'Name'.</p>
  </blockquote>
  
  <p>Looks like SQL Server uses old schema for <code>Table2</code> (which indeed hasn't these columns), but how is this possible, if the table has just created with new schema?  </p>
  
  <p>What am I doing wrong?  </p>
  
  <p>Server version is SQL Server 2012 (SP1) - 11.0.3128.0 (X64).</p>
  
  <p><strong>UPDATE</strong>.</p>
  
  <p>I've added <code>PRINT</code> calls (see script above). There's nothing in message window, except error messages. So, the script isn't being executed... What's going on??</p>