title: Select Into Explanation / Temporary Tables
body: <p>Based on the tutorial on <a href="http://www.youtube.com/watch?v=3ZtYrELHP8M" rel="nofollow">SQL Temporary Tables</a>, it should be OK to create a temp table by using <code>SELECT * INTO #tempTable FROM tableA</code> but it's throwing me <code>SQLException</code> when I trying to <code>SELECT * FROM #tempTable</code> saying that <code>Invalid object name '#tempTable'</code>. May I know what's the proper way of using a temp table in <code>C#</code>?</p>
  
  <pre><code>string sql = "SELECT * INTO ##tempTable FROM (SELECT * FROM tableA)";
  using (var command = new SqlCommand(sql, connection))
  {
      string sqlNew = "SELECT * FROM ##tempTable";
      using (var command2 = new SqlCommand(sqlNew, connection))
      {
          using (var reader = command2.ExecuteReader())
          {
              while (reader.Read())
              {
                  Console.WriteLine(reader["column1"].ToString());
  
              }
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p>My Objective is tryint to using the data retrieved from <code>sqlVar</code> and insert them into a tempTable and perform some operation on it. Very much appreciated if there is some sample code on how to fit the code into the above code. Thank You.</p>