title: How to set and return a variable in a Sybase stored procedure
body: <p>I've tried to read up on Sybase but the information that I'm getting is too unclear for me. The issue that I'm having is that I have to edit this 6000 line stored procedure in Sybase. Needless to say it's a complete nightmare, especially for someone who's strongest point isn't exactly SQL.</p>
  
  <p>At the top of the procedure there's a variable declared (just using shorter variable names for the sake of this question):</p>
  
  <pre><code>DECLARE @MY_VARIABLE INT
  </code></pre>
  
  <p>The little SQL I'm familiar with is SQL Server, and Sybase is feeling quite a bit different. How exactly do you set a value to that variable? In SQL Server I'd image it would be something like this:</p>
  
  <pre><code>SET @MY_VARIABLE = 1
  </code></pre>
  
  <p>However I can't find any place in the procedure where something like this happens. I did find this though:</p>
  
  <pre><code>SELECT @MY_VARIABLE = convert(integer, Member_Number)
  FROM ELECTRONIC_FORM NOHOLDLOCK
  </code></pre>
  
  <p>Is this how you set a variable in Sybase? With</p>
  
  <pre><code>SELECT @MY_VARIABLE = 2
  </code></pre>
  
  <p>for example?</p>
  
  <p>Besides that, how do I return the value of the variable at the end of the procedure? I would've imagined it be something like this:</p>
  
  <pre><code>SELECT @MY_VARIABLE
  </code></pre>
  
  <p>And just make sure it's the last thing in the procedure but that doesn't seem to work. And it's looking quite similar to the way I have a feeling a variable actually gets <em>set</em> and not <em>selected</em>. I'm just really confused and lost here, thanks in advance for any help out there!</p>