I want to create a table in which the column names have spaces.
like
create table IDE_Dump(
Name varchar(255),
Head Name varchar(255),
Parent Account varchar (255)
);
The problem is to import bulk data from excel sheet to SQL Server 2008, whose headers are having the columns with spaces.
I have already tried ' ' or ` but its not working.
DML SQL query with space in a column name When we run INSERT, UPDATE, and DELETE statements, we must use a square bracket or double quotes to handle the column name with space.
Column names can contain any valid characters (for example, spaces).
Table names can contain any valid characters (for example, spaces).
SQL Server TRIM() Function The TRIM() function removes the space character OR other specified characters from the start or end of a string. By default, the TRIM() function removes leading and trailing spaces from a string. Note: Also look at the LTRIM() and RTRIM() functions.
You need to add []
brackets to column name.
CREATE TABLE IDE_Dump
(
Name VARCHAR(255),
[Head Name] VARCHAR(255),
[Parent Account] VARCHAR(255)
);
Or you can use double quotes ""
as jarlh commented:
CREATE TABLE IDE_Dump
(
Name VARCHAR(255),
"Head Name" VARCHAR(255),
"Parent Account" VARCHAR(255)
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With