title: SQL Server 2005: Determine datatype of variable
body: <p>Is it possible to determine the type of a local variable at runtime in TSQL?</p>
  
  <p>For example, say I wanted to do something along these lines:</p>
  
  <pre><code>IF ( @value IS INTEGER )
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>IF ( TYPEOF(@value) = &lt;whatever&gt; )
  </code></pre>
  
  <p>Does anyone know of any way to accomplish this?</p>
  
  <p>EDIT: This is not for a specific task, this is more of a general knowledge question. I do appreciate answers that indicate that the type should be known since it is declared within the same batch, I am curious as to whether the type can be determined at runtime.</p>