title: How do I get SQL SELECT @variable = expression assignments to work like a spreadsheet?
body: <p><em>Disclaimer: This is an "asked-and-answered question" posted in accordance with the FAQ statement that it's "perfectly fine to ask and answer your own programming question". Its purpose is to encourage members of the SQL Anywhere programming community to use StackOverflow by seeding the "sqlanywhere" tag with some real-world content. Edits are welcome, as are other answers, and it has been marked "community wiki" to facilitate that, as well as to avoid claims of gaming the reputation system.</em></p>
  
  <p>I'm writing a stored procedure for SQL Anywhere 9.0.2, here's some code:</p>
  
  <pre><code>...
  declare
  @v_d datetime, @v_d1 datetime, @v_d2 datetime
  ....
  select @v_d1 = @v_d, @v_d2 = dateadd(dd, 1, @v_d1)
  ...
  </code></pre>
  
  <p>it turns out that @v_d2 will not be set as expected.
  if I modify it to:</p>
  
  <pre><code>...
  declare
  @v_d datetime, @v_d1 datetime, @v_d2 datetime
  ....
  select @v_d1 = @v_d
  select @v_d2 = dateadd(dd, 1, @v_d1)
  ...
  </code></pre>
  
  <p>nothing happens, all the same.
  finally, I changed it to :</p>
  
  <pre><code>...
  declare
  @v_d datetime, @v_d1 datetime, @v_d2 datetime
  ....
  begin
     select @v_d1 = @v_d
  end
  begin
     select @v_d2 = dateadd(dd, 1, @v_d1)
  end
  ...
  </code></pre>
  
  <p>now it works fine, looks kind of stupid though.
  my question is: is it a known issue? or maybe I could do it more neatly? any 
  comments will be appreciated.
  thanks! </p>