Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 " ' " in select statments

Author  Topic 

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2003-01-27 : 21:00:40
I have a select statment that pulls info based on a person's location but I ran into a small issue the location has an "'" in it and that is causing an error. How can I keep the "'" in the location and have the select statment work?



--
For those with wings, fly to your dreams

Dearms are what are found at the end of reality, and your reality if what is found at the end of your dreams.

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-01-27 : 22:17:29
Hi

You can escape apostrophes by using two apostrophes.

If you are building this into a web app, replace all user input to escape these with something like :



location = request.form("location")
location = replace(location, "'", "''")



Damian
Go to Top of Page

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2003-01-27 : 22:56:54
That worked thanks.

--
For those with wings, fly to your dreams

Dearms are what are found at the end of reality, and your reality if what is found at the end of your dreams.
Go to Top of Page
   

- Advertisement -