title: How to write an equivalent IF ELSE adhoc sql query in Snowflake
body: <p>I am trying to create a Snowflake equivalent to the below T-SQL based adhoc query.</p>
  <pre><code>**T-SQL version**
  Declare @i int = 0;
  
  If(@i = 0)
     PRINT '0';
  Else
   Begin
     PRINT '1'
     RETURN;
     PRINT '2'
   End
  
  
  **Snowflake version**
  Set i = 0;
  
  If($i = 0)
     Select '0';
  Else
   Begin
     Select '1'
     RETURN;
     Select '2'
   End
  
  </code></pre>
  <p>When I am running the Snowflake query from the Snowflake Web UI, I am getting an error as</p>
  <blockquote>
  <p>SQL compilation error : syntax error line 1 at position 0 unexpected 'IF'</p>
  </blockquote>
  <p>I have searched the snowflake documentation and did not find helpful documentation for:</p>
  <ol>
  <li>If Else</li>
  <li>Begin End</li>
  <li>Return</li>
  </ol>
  <p>Any help would be appreciated.</p>
  <p>Thank you.</p>