I want to create a table in SQL Server2012 which has column name which includes parenthesis as
create table temp_sp
(
logtime datetime,
vcs_api varchar,
L3(S1)Status varchar,
L3(S2)Status varchar,
beam_current real,
beam_energy real,
st1_vs1_bag1_rb real,
ring_avg_pressure real
)
But when I use parenthesis with L3(S1)Status
, L3(S2)Status
then I get an error
Incorrect Syntax near '('.Expecting ')'or ','.**
How to resolve it?
Parenthesis , single comma are reserved word for sqlserver. Generally avoid this type of thing.
Still you want , you need to use Bracket []
for this to tell sqlserver that it is the string , not reserved word.
So [L3(S1)] Status varchar
this will work for you.
Good article :- http://technet.microsoft.com/en-us/library/aa224033%28v=sql.80%29.aspx
Which "special" characters are allowed in SQL Server varchar fields?
What characters are valid in an SQL Server database name?