title: Select @Var into temp table
body: <p>In my procedure I am loading declared variables with values then trying to put the variables into a temp table. I am doing this:</p>
  
  <pre><code>select cast(@rec_cnt as varchar(5), @tbl_name
  INTO #TEMP_TBL_DUP_CNT
  </code></pre>
  
  <p>But keep getting msg: Incorrect syntax near ','. That is, the comma between columns is causing an issue when I try execute proc. What is wrong with this statement?</p>
  
  <p>I've checked temp table doesn't already exist as it shouldn't anyway.</p>
  
  <p>I just ran a similar query to load the table data into a temp table and that worked. Can I not used directly the declared variable values, if so what do I do otherwise?</p>
  
  <p>EDIT: Also wanted to ask how can I query this temp table. I understand I need to do it in scope of the SP, what kind of variable can I load all the result into? I was thinking that I would need to select into the variable from temp table then print?</p>
  
  <p>Thanks</p>
  
  <p>Andrew</p>