title: A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations1
body: <p>I keep getting this error </p>
  
  <blockquote>
    <p>A SELECT statement that assigns a value to a variable must not be
    combined with data-retrieval operations</p>
  </blockquote>
  
  <p>when I run this code:</p>
  
  <pre><code>SELECT 
      @i = Users,
      (NAME + ' ' + Surname) AS names
  FROM   
      dbo.HelpDeskUsers
  WHERE  
      [names] LIKE @userid 
  </code></pre>
  
  <p>I tried another way ...</p>
  
  <pre><code>SET 
    @i = (SELECT  
              [Users],
              ([Name] + ' ' + [Surname]) AS [names]
          FROM  
              dbo.HelpDeskUsers
          WHERE  
              Names LIKE @userid) 
  </code></pre>
  
  <p>and I get this error:</p>
  
  <blockquote>
    <p>Msg 207, Level 16, State 1, Procedure test, Line 17<br>
    Invalid column name 'Names'</p>
    
    <p>Msg 116, Level 16, State 1, Procedure test, Line 19<br>
    Only one expression can be specified in the select list when the subquery
    is not introduced with EXISTS.</p>
  </blockquote>