[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 609
  • Last Modified:

apostrophe in an SQL update

Having problem to update a comment field when user puts an apostrophe
0
badrul_hossain
Asked:
badrul_hossain
1 Solution
 
TimCotteeCommented:
Hi badrul_hossain,

Double the apostrophe:

"Update MyTable Set MyField = '" & Replace(MyValue,"'","''") & "' Where MyOtherField = Something"

In principle, SQL server will see the two '' characters and only store one of them.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
vnvkCommented:
This Question is now classified abandoned as no comment has been added to this question in more than 21 days.

I will leave the following recommendation on this question to the moderators in the Cleanup topic area:
    Accept: TimCottee {http:#9747797}

Any objections should be posted here in the next 4 days. After that time, the question will be closed at the discretion of the moderator.

vnvk
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now