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.

Re: Update statement in SQL 80 80

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", " ' ", " '' ")
Re: Update statement in SQL 80 80

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.

Re: Update statement in SQL 80 80

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?

Re: Update statement in SQL 80 80

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 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.