I have this function in SQL Server to replace single quotes.
But when I insert a single quote it throws an error on Replace(@strip,''',''))
:
Create Function [dbo].[fn_stripsingleQuote] (@strStrip varchar(Max)) returns varchar as begin declare @CleanString varchar(Max) SET @var=(Replace(@strip,'','')) return @var end
Use the String. replace() method to replace single with double quotes, e.g. const replaced = str. replace(/'/g, " ); . The replace method will return a new string where all occurrences of single quotes are replaced with double quotes.
The short answer is to use two single quotes - '' - in order for an SQL database to store the value as ' .
You need to double up your single quotes as follows:
REPLACE(@strip, '''', '')
Try REPLACE(@strip,'''','')
SQL
uses two quotes to represent one in a string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With