SQL

Start Here Glossary WHERE INSERT (Create) SELECT (Read) UPDATE DELETE Join Tables Sub Query Limit Records SQL Injection SSMS Meta Data Sum TABLE Apostrophe Date Identity
O O

Weather Controls

Time Of Day
Rain
Wind Speed
Wind Direction
Clouds

SQL : Apostrophe

2019-02-26

How to handle an apostrophe in a string in vbscript and TSQL.

name = "Pat E O'Furniture"

Option 1

Replace single quote with with 2 signle quotes to escape it.

name = replace(first,"'","''")
OConn.Execute ("Update myTable Set name ='"&name &"' WHERE ID= 1")

Option 2

This will automatically fix it.

Set rsData = RS("SELECT name FROM myTable WHERE ID= 1", 2)
rsData("name") = name
rsData.update