title: INSERT statement cannot contain a SELECT statement -sql server2012
body: <pre><code>    declare @us table(name nvarchar(100),lastname nvarchar(100),UID bigint,available bit);
          declare
          @Name nvarchar(100),
          @lastname nvarchar(100),
          @UID bigint,
          @Avail bit
  
          insert into @us
          select @name=name,@lastname=lastname,@UID=UID,@Avail=available from Users where available='1'
   select * from @us
  </code></pre>
  
  <p>I got this error </p>
  
  <blockquote>
    <p>An INSERT statement cannot contain a SELECT statement that assigns
    values to a variable.</p>
  </blockquote>
  
  <p>I searched for this problem but many people used queries like this and they said <em>there is no problem</em>!  i'm using sql server 2012, is it a deference between MSSQL2012 and MSSQL2008? and what is the best solution if I want to return a table from my Stored Procedures? what is wrong in my query?</p>