How can I refer to a column with a space in the name?

I am trying to run an instruction in which I get tuples from a database. However, my attribute has a space, which is "Status Name".

I call the SQL statement as follows:

select * from States where State Name = 'Michigan'; 

I am sure something is wrong with an attribute having a space. How can I fix this problem without changing the attribute name? How can I call an SQL statement with an attribute constraint that has a space?

Thanks,

+4
source share
3 answers
 select * from States where [State Name] = 'Michigan'; 
+8
source

Try throwing square brackets around it:

 select * from States where [State Name] = 'Michigan'; 
+2
source

The standard SQL delimiter (and is supported by SQL Server) is a double quote, for example.

 SELECT * FROM States WHERE "State Name" = 'Michigan'; 
+2
source

All Articles