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
 SQL Server Development (2000)
 Handling Single Quotes with Replace function in SQL SERVER2000

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-04 : 08:17:02
Murali SN Rao writes "Hi,

We need to accept single quotes with the data as being entered by the user in the applicatioon we are developing.

We know that the same can be done by using the Replace function as provided by VB6.

We are trying to achieve the same by using the Replace function as provided by SQL Server2000. We are using Stored Procedures for all DB transactions and we would wanna use the same for handling single quotes as well.

Now the issue is that SQL Server throws up an error as soon as it identifies 2 single quotes.

Can anyone lemme know as to how to use the Replace function in SQL Server 2000 in Insert and Update statements and particularly with Single Quotes..:)

Awaiting your reply

regards
Murali SN Rao"

Nazim
A custom title

1408 Posts

Posted - 2002-06-04 : 08:31:21
you can always use single quotes in replace by adding a extra single quote to it.

check this article http://www.sqlteam.com/item.asp?ItemID=293 .

--------------------------------------------------------------
Go to Top of Page

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-06-04 : 09:57:16
it's good design practice to generally wrap any string parameter with the t-sql function QUOTENAME(). Not only will this escape single quotes, but all other system characters as well.

setBasedIsTheTruepath
<O>
Go to Top of Page
   

- Advertisement -