July 10, 2012 at 11:45 pm
Hi Everyone,
I have a T-sql to show you which throws an error when we run it.Please help in understanding the problem here and provide the solution .Below is the t-sql which throws an error :
CREATE TABLE QCHECK([Access Chapter 1 Big Name [ment]] VARCHAR(100))
Regards
Chaithanya M
July 11, 2012 at 1:24 am
Hi,
thanks fore reply.Could you please expalain how this worked by adding a ']'. How does sql server treat this ?
Regards
Chaithanya M
July 11, 2012 at 5:38 am
If you want Access Chapter 1 Big Name [ment] as your column name, the below query should give you the exact way to represent your column name in the table definition
SELECT QUOTENAME('Access Chapter 1 Big Name [ment]')
You will have to add 2 closing brackets for 1 opening bracket inside your main opening/closing bracket.
Sounds confusing, right!! Try some combinations with the query provided, you will understand.
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
July 11, 2012 at 7:00 am
Hi,
SQL Server allows any character in the current code page to be used in a delimited identifier. For example, you can create a table with the name Employee], where the closing square bracket is part of the name. To do this you have to escape the closing square bracket with two more square brackets as shown in the above example by okbangas.
Regards,
Ravi.
July 11, 2012 at 7:11 am
My advice is to save yourself a world of pain, and restrict names of databases, objects, columns etc to alphanumeric characters and underscores.
John
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply