• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to compare text value that has special character using SQL in VBA

kailashxl

New Member
I am using ADODB in Excel and writing SQL query to compare names form one source excel file with that of other excel file. However therein I got stuck as couple of name in the source file having special character like Mike'O Brian. it's throwing error "Syntax Error (missing operator) in query expression. Any help around this would be highly appreciated.
 
Are you using the name in the query?

If so, you need to escape single quote by using 2 single quotes.

Ex: '' instead of '
 
I am currently working on the data where we have the hierarchy of members which might go up to any level (sample data and required output is shown below. The sample data is having limited rows but the actual data will have rows running in thousands and have to showcase the result upto say 5, 6 or may be more levels.

Any help on adapting the most optimized approach for getting the desired result using Excel VBA (I am trying here to use ADODB SQL). Please suggest/share your thoughts on the approach plan.
Thanks in advance for your help.

member IDMember NameLead_IDCity
Lead1LeaderCity 1
Member1Member OneLead1City 2
Member2Member TwoLead1City 22
Member3Member ThreeLead1City 2
Member11Member ElevenMember1City 3
Member12Member TwelveMember2City 4
Member13member ThirteenMember1City 3
Member17Member SeventeenMember1City 7
Member 9Member NineMember13City 9
Required Outcome:
Top LevelLevel1Level2Level3Level4City
LeaderCity 1
LeaderMember OneCity 2
LeaderMember OneMember ElevenCity 3
LeaderMember OneMember ThirteenCity 3
LeaderMember OneMember ThirteenMember NineCity 9
LeaderMember OneMember SeventeenCity 7
LeaderMember TwoCity 22
LeaderMember TwoMember TwelveCity 4
LeaderMember ThreeCity 2
 
Are you using the name in the query?

If so, you need to escape single quote by using 2 single quotes.

Ex: '' instead of '
Thanks Chihiro for your revert- Tried that but not working for me. If your could explain this with example. Thx
 
Back
Top