Hi there here is a stupid question. I have created an update statement that updates a table that has null user id using a name as the identifier:

UPDATE dembel
SET userid = 8908
WHERE [Name] = 'o'reily'

However the the name already contains an apostrophe which causes a problem in sql, How can i write the name so that the apostrophe is part of the string itself.

Recommended Answers

All 4 Replies

Something like that might work:

UPDATE dembel

SET userid = 8908

WHERE [Name] = 'o''reily'

But before doing that you need to replace the name in ur db with double apostrophe using Replace:

Replace ("o'reily", " ' ", " '' ")

Something like that might work:

UPDATE dembel

SET userid = 8908

WHERE [Name] = 'o''reily'

But before doing that you need to replace the name in ur db with double apostrophe using Replace:

Replace ("o'reily", " ' ", " '' ")

Why would he replace the data with a double apostrophe? That's changing the integrity of the data, which I don't think he wants.

That's one solution and if he doesn't want it he could do sth else but do u have any suggestion in this regard?

Try this one it works!

UPDATE dembel
SET userid=8909
WHERE Name='o''reily'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.