For an application we need to connect to an SQL Server 2008 to do some queries.
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: TRP$Lease Car
for example.
The studio get data by this query:
SELECT TOP 1000 *
FROM [Mdatabase].[dbo].[TRP$Lease Car]
When I run this query in my PHP installation it fails on the $
sign:
$data = $this->db->query("SELECT * FROM dbo.TRP$Lease Car");
Like this:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: Lease
Filename: views/welcome_message.php
Line Number: 5 A Database Error Occurred
Error Number: 42S02
[Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid object name 'dbo.TRP'.
How do I need to call these tables when running an query from my PHP?
EDIT
The problem only appears on tables with an space in the name... An query with TRP$Invoice
works. In this case TRP$Lease Car
is the problem I think..