DineshDB DineshDB - 6 months ago 14
MySQL Question

How to create a column name with space in SQL Server

I want to create a column name in a table with space. In MySQL I just created this using the back ticks. But in SQL Server it was show an error. Is there any possibilities to create a column name with space.

I've tried like the following but it doesn't work.

create table space_check
(
`roll num` int,
name varchar(50)
)


Can anybody tell me how to create this. Thanks in advice.

Answer

Give the column name within Square brackets.

create table space_check
(
  [roll num] int,
  name varchar(50)
)

It was not a good practice. Try to create using underscore(roll_num) or caps(rollNum).