Click here to Skip to main content
15,888,301 members
Please Sign up or sign in to vote.
4.20/5 (2 votes)
See more:
how to create a column name like this in sql
897455X7X35 char(1) DEFAULT NULL,

What I have tried:

897455X7X35 char(1) DEFAULT NULL,
Posted
Updated 8-Jun-16 20:31pm

Yes, you can do that. All you have to do is wrap the column name in brackets. Please see code below.
SQL
ALTER TABLE Employee
ADD [897455X7X35] char(1) DEFAULT NULL;
 
Share this answer
 
Normally, it's a bad-practice to name a table column starting with non-alphabet characters. Having said that, you should be able to enclose your column name in braces (like in your SELECT query example).
see below query snippet
SQL
ALTER TABLE Employee ADD [897455X7X35] char(1) DEFAULT NULL;
 
Share this answer
 
Comments
kumari567 9-Jun-16 2:44am    
thanku for reply ....but reply is little late ...I did this like
ALTER TABLE Employee ADD "897455X7X35" char(1) DEFAULT NULL;
Magic Wonder 9-Jun-16 2:52am    
+5 for your suggestion..."Its a bad practice."
kumari567 9-Jun-16 2:59am    
yes I know .....But whatever the requirement we have to do that .....bcz I m doing this for another one

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900