title: How can I set multiple T-SQL variables in a single SELECT query?
body: <p>I have 3 variables: <code>@testid</code>, <code>@sampleid</code> and <code>@clientid</code>.</p>
  
  <p>How can I set <code>@sampleid</code> and <code>@clientid</code> by executing this query once?</p>
  
  <pre><code>SELECT
    [sample].sampleid,
    [client].clientid
  FROM
    dbo.[test]
    LEFT OUTER JOIN dbo.[sampleslice] ON dbo.[test].samplesliceid = dbo.[sampleslice].samplesliceid
    LEFT OUTER JOIN dbo.[sample] ON dbo.[sampleslice].sampleid = dbo.[sample].sampleid
    LEFT OUTER JOIN dbo.[client] ON dbo.[sample].clientid = dbo.[client].clientid
  WHERE
    testid = @testid
  </code></pre>