I have the following situation, I was asked to make a project with an SQL database already created but I find that the names of the tables and the fields of the tables are written with spaces and when I try to execute my query it sends me a syntax error . This database is working with an application made in Visual Basic and I am making a web application with php. Here is my code:
Select Customer.AR Cust Password, Customer.AR Cust User Name FROM AR Customer AS Customer
Mistake:
19:04:05 Kernel error: [FreeTDS][MSSQL Server] , Server EC2AMAZ-977S99A\APPBSC, Line 1 Incorrect syntax near 'Password'.
In SQL Server the delimiters for identifiers that can be used are:
delimiters
Although both are equally valid, double quotes can sometimes be invalid.
Set Quoted_Identifier
the sql interpreter does not distinguish between fields and columns and that it has spaces.. when you call these it must go over square brackets
if you call them like this:
if you need to rename the column to parse it into an object you can do it like this
the engine does not know how far the columns and tables are
Here you can see an example
in the last line there is a query with an error (without brackets)
I hope the information is useful to you
just use backticks
`nombre de tabla`
Alt Gr+ { or } to get them