title: Run queries to MS SQL server with strange table names
body: <p>For an application we need to connect to an SQL Server 2008 to do some queries. </p>
  
  <p>I run the queries in PHP on an Codeigniter Framework. I get access to this SQL database by an program called "Microsoft SQL server management studio". The tables have strange names with dollar signs: <code>TRP$Lease Car</code> for example. </p>
  
  <p>The studio get data by this query:</p>
  
  <pre><code>SELECT TOP 1000 *
    FROM [Mdatabase].[dbo].[TRP$Lease Car]
  </code></pre>
  
  <p>When I run this query in my PHP installation it fails on the <code>$</code> sign:</p>
  
  <pre><code>$data = $this-&gt;db-&gt;query("SELECT * FROM dbo.TRP$Lease Car");
  </code></pre>
  
  <p>Like this:</p>
  
  <blockquote>
    <p>A PHP Error was encountered</p>
    
    <p>Severity: Notice</p>
    
    <p>Message: Undefined variable: Lease</p>
    
    <p>Filename: views/welcome_message.php</p>
    
    <p>Line Number: 5 A Database Error Occurred</p>
    
    <p>Error Number: 42S02</p>
    
    <p>[Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object
    name 'dbo.TRP'.</p>
  </blockquote>
  
  <p>How do I need to call these tables when running an query from my PHP?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The problem only appears on tables with an space in the name...  An query with <code>TRP$Invoice</code> works. In this case <code>TRP$Lease Car</code> is the problem I think.. </p>