Reputation: 975
Can I declare name of SQL Server variable in a table with spaces?
create table test(
record name, float, not null
.....
The above query when executed gives me an error. Is there any way to declare the variable as
variable name
with a space..??
Upvotes: 0
Views: 2483
Reputation: 2952
use [square brackets]
around your column names with spaces and you should be fine.
It would be advisable in the long term to avoid spaces all together if you can, it will save you hours of stress in the future.
Upvotes: 0
Reputation: 4001
Try using square brackets:
create table test(
[record name] float not null)
Upvotes: 1
Reputation: 79969
Yes, escape these names using []
:
[record name] ....
These names are called Delimited identifiers
:
Are enclosed in double quotation marks (") or brackets ([ ]).
But it is not recommended, use legal names instead or regular identifiers.
Upvotes: 8