472,333 Members | 1,092 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,333 software developers and data experts.

SQL statement with quotation marks

I am trying to create a recordset where some text fields are matching. The
problem is that some of the text fields contain quotation marks. I have
tried to create the sql string using replace eg.
"SELECT * FROM MYTABLE WHERE REPLACE(MYFIELD,"""",".") = """ &
REPLACE(MYTEXT,"""",".") & """"
but this does not work. Trying to replace the quotation marks with some
other character in this case the stop
How can I embed the quotation marks in the sql string?

Alex
Nov 13 '05 #1
7 11415
jv
Alex,

I also use the replace() function to eliminate quotations and
apostrophes for SQL statement and it works great for me (I actually
replace it double apostrophes, which becomes a single apostrophe).

Why is the WHERE clause REPLACE(MYFIELD,"""",".")= """ ?

Trying putting a breakpoint in VBA and then evaluate that SQL string in
the Immediate window.

Good Luck

Nov 13 '05 #2
My staement is
STRSQL = "SELECT * FROM TBLINMAIL WHERE replace(Subject,"""",".") = """ &
Replace(mySubject, """", ".") & """"

but it shows in red as incorrect
"jv" <ju***********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Alex,

I also use the replace() function to eliminate quotations and
apostrophes for SQL statement and it works great for me (I actually
replace it double apostrophes, which becomes a single apostrophe).

Why is the WHERE clause REPLACE(MYFIELD,"""",".")= """ ?

Trying putting a breakpoint in VBA and then evaluate that SQL string in
the Immediate window.

Good Luck

Nov 13 '05 #3
Try this:

STRSQL = "SELECT * FROM TBLINMAIL WHERE Subject = '" &
Replace(mySubject, """", ".") & "'"

I don't think you need to put replace() around the field name part of
the expression, only around the value part.

Good Luck.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4
Yes that works BUT I also need to replace the subject in the string with a
replace
eg.
STRSQL = "SELECT * FROM TBLINMAIL WHERE REPLACE(SUBJECT,"""",".") = " ETC
and it seems that I cannot use the replace in a query
Alex

"julie vazquez" <ju***********@hotmail.com> wrote in message
news:41**********@127.0.0.1...
Try this:

STRSQL = "SELECT * FROM TBLINMAIL WHERE Subject = '" &
Replace(mySubject, """", ".") & "'"

I don't think you need to put replace() around the field name part of
the expression, only around the value part.

Good Luck.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #5
I don't see why you need to put a replace around your table field name.
It doesn't make sense.

But if you wish, you can put it like this:

strSQL = "SELECT * FROM TBLINMAIL WHERE replace(Subject,'""','.') = '" &
Replace(mySubject, """", ".") & "'"


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #6
Do a google search for quotes in strings. Also check The Access Web
which has an elegant solution using Const cQuote = """"

Goog luck!
julie vazquez wrote:
I don't see why you need to put a replace around your table field name. It doesn't make sense.

But if you wish, you can put it like this:

strSQL = "SELECT * FROM TBLINMAIL WHERE replace(Subject,'""','.') = '" & Replace(mySubject, """", ".") & "'"


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 13 '05 #7
Paradigm wrote:
I am trying to create a recordset where some text fields are matching. The
problem is that some of the text fields contain quotation marks. I have
tried to create the sql string using replace eg.
"SELECT * FROM MYTABLE WHERE REPLACE(MYFIELD,"""",".") = """ &
REPLACE(MYTEXT,"""",".") & """"
but this does not work. Trying to replace the quotation marks with some
other character in this case the stop
How can I embed the quotation marks in the sql string?

Alex


Why are you needing that? And your logic of trying to replace quotes
with a period and comparing them to a quote doesn't make sense. Check
the following line....it's more to what you want.

"SELECT * FROM MYTABLE WHERE REPLACE(MYFIELD,"""""",""."") =
REPLACE(MYTEXT,"""""",""."")"
To verify the above, Go to the Debug/Immediate Window. Enter
v = "SELECT * FROM MYTABLE WHERE REPLACE(MYFIELD,"""""",""."") =
REPLACE(MYTEXT,"""""",""."")"

? v

this will echo back
SELECT * FROM MYTABLE WHERE REPLACE(MYFIELD,""",".") =
REPLACE(MYTEXT,""",".")

Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: NikkoW | last post by:
I need to assign a string to a variable but the text string includes quotation marks: Example: MyString = "He turned and said "Hello" before...
8
by: Stephen Poley | last post by:
One disadvantage of using a simple text editor to produce HTML is that it is relatively time-consuming to put in the proper typographical quotation...
63
by: Tristan Miller | last post by:
Greetings. Do any popular browsers correctly support <q>, at least for Western languages? I've noticed that Mozilla uses the standard English...
0
by: Aaron Deskins | last post by:
Hello all, I'm trying to set up a database to track articles and documents. I've created a Table to hold the information I need. I've set up one...
2
by: Dixie | last post by:
Hi, I am tyring to write some generic code that will send the source SQL for a mailmerge to a Word template. I am trying to use DLookup to insert...
3
by: Ufit | last post by:
Simple,dumm question - how to include quotation marks in the string? F.ex. "Data Source=.\SQLEXPRESS;AttachDbFilename="C:\client...
1
by: nonni | last post by:
Hi. I came across this site while looking for a function to replace Quotation marks in SQL. This is my code. <!-- Begin Code --> Intro =...
31
by: The Bicycling Guitarist | last post by:
Hi. For many years I have been using &quot; for double quotation marks in the HTML code, but the opening and closing quotation marks render the same in...
12
by: Adam Right | last post by:
Hi ! In my sql statement, i have to use field names and table name with quotation marks. like that :...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.