title: Begin...End blocks in SQL Server: Is this code right?
body: <p>I just want to verify that I'm not missing something here... so bear with me.</p>
  
  <p>I'm rewriting a lot of old stored procedures and keep seeing IF statements formatted similar to this:</p>
  
  <pre><code>begin
      if @someParameter &lt;&gt; 'ThisType'
      set @someCode = right(cast(@pYear as varchar(6)),2) + 'THIS'
  end
  </code></pre>
  
  <p>So the Begin...End block just wraps (but does not effect) the IF statement, right? Is this some older syntax for IF or something?</p>
  
  <p>The guy who wrote this didn't have a lot of SQL experience prior to this job; he worked mostly in VB (pre-.NET). Maybe this is syntax from some other language, so he accidentally wrote it this way (by habit)?</p>
  
  <p>This is SQL Server 2005 (code was written on/for SQL Server 2000), btw</p>
  
  <p>Like I said, I'm just trying to wrap my brain around this spaghetti. Any thoughts/comments/illuminating insights are welcome</p>
  
  <p>Thanks</p>