Whst does these brackets mean in the sql statement

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

This statement is in a book that I'm reading and I just wonder what the
brackets mean that exist around Order Details in the
sql statment.

SqlCommand command = new SqlCommand("WAITFOR DELAY '00:00:05'; " +
select
* from [Order Details]", myConnection);

//Tony
 
The [] are used like "" or '' other places, for table names in SQL.

You might also see a table in a database wrote like this.
[database].[schema].
 
This statement is in a book that I'm reading and I just wonder what the
brackets mean that exist around Order Details in the
sql statment.

SqlCommand command = new SqlCommand("WAITFOR DELAY '00:00:05'; " +
select
* from [Order Details]", myConnection);

Because there is a table name with a space in, then you need to
tell the SQL parser that the two words are a single name.

SQLServer and Access uses [bla bla] for that purpuse.

MySQL uses `bla bla` (forward leaning single quotes) for
that purpose.

The SQL standard suggests "bla bla".

The correct solution is to avoid spaces in names (and
names that are reserved keywords) and not this hack, because
it makes the SQL non portable.

Arne
 
Back
Top