How To Query Sql Columns That Have Parentheses ( ) In Their Name?
The column names looks something like: 'Ab. (Cd)' It has , '.' as well as ( ) in the column name. I have tried square brackets [ ] around the column name and have also tried ' ' a
Solution 1:
Your query:
Select'Trans. Z4 (St 85)'from'Monthly Prices$'You cannot SELECT from a string. You need to use square brackets around the table name:
Select'Trans. Z4 (St 85)'from [Monthly Prices$]
But that's only half of the problem. If you run this, you will get the same string, "Trans. Z4 (St 85)" on every row. You need to use square brackets for that column name as well:
Select [Trans. Z4 (St 85)]from[Monthly Prices$]Solution 2:
I think it is the wizard which is your problem. Often the wizards will not have as robust an understanding of SQL as writing the statement in SSMS. I was able to create a spreadsheet with your column names but was only able to import it with the wizard if I imported the whole table not using a sql statement. Is this a possibility for you? I could query the table using brackets properly in SSMs afterwards with these names.
Post a Comment for "How To Query Sql Columns That Have Parentheses ( ) In Their Name?"