I really need some advice on this. Please. I have a oracle table having column names with spaces. I made a code having sql select query inside, which extracts data accordingly. It works for column name without spaces like "select column from table". i need to make work this in vba "select column name from table". What delimeters should i use. Have tried {},[],``. Please help
Asked
Active
Viewed 328 times
0
-
1`"` did you try that? – Nathan_Sav Sep 05 '17 at 07:48
-
Yes i tried " " in vba code. Didn't work. marks it red. – Ashish Virmani Sep 05 '17 at 08:01
-
you'll need to double them up etc, in strings as it will terminate them. – Nathan_Sav Sep 05 '17 at 08:28
2 Answers
1
You need to use double quotes to surround an identifier with special characters:
SELECT "Column 1" FROM your_table
This will enforce case-sensitivity on the column identifier; so, you need the string to be in the exact case that it was used in the database.
If you are using it in a string in VBA then you will need to escape the quotes (so they do not terminate your string):
"SELECT ""Column 1"" FROM your_table"

MT0
- 143,790
- 11
- 59
- 117
0
You shoould use double quotes - the original Oracle notation.
create table test("Column 1" varchar2(10), column_2 number);
insert into test values('Mickey', 1);
insert into test values('Donald', 2);
insert into test values('Goofy', 3);
select * from test;
select "Spalte 1" from test;
For the quotes you can concat CHR(34).
"select " & CHR(34) & "Spalte 1" & CHR(34) & " from test"

Holger Böcher
- 1
- 1