title: Why doesn't SQL Server's OBJECT_ID(NVARCHAR) take a variable?
body: <p>So why doesn't this work?</p>
  
  <pre><code>&lt;!-- language: lang-sql --&gt;
      DECLARE @tn NVARCHAR
      SET @tn = 'MyTable'
      SELECT OBJECT_ID(@tn)
  </code></pre>
  
  <p>When this does:</p>
  
  <pre><code>&lt;!-- language: lang-sql --&gt;
      SELECT OBJECT_ID('MyTable')
  </code></pre>
  
  <p>I need to pass a variable into this function.</p>