user3515219
user3515219

Reputation: 29

Remove special character in sql

REPLACE(ab.FirstName,', '')

How can i remove only this character ' from a string in sql

Upvotes: 0

Views: 381

Answers (5)

Ronak Patel
Ronak Patel

Reputation: 640

Please check my solution .

 DECLARE @stringdata nvarchar(500)='ronak'''
 select @stringdata
 select REPLACE(@stringdata,'''', '')

Original string is "ronak'patel" .

String after removing single quotation is "ronakpatel".

Thanks .

Upvotes: 0

Vikrant
Vikrant

Reputation: 5036

If you are fetching records from existing table:

select REPLACE(ab.FirstName,'''', '')

If you are comparing values:

select REPLACE(name,'''', '')
from Table1
where name ='AB O''Donnell'

Upvotes: 0

Husen
Husen

Reputation: 1587

Try this one

SELECT REPLACE(ab.FirstName,'''', '') as FirstName

For more details like

Upvotes: 0

user3146115
user3146115

Reputation:

You need to double up your single quotes like below

REPLACE(ab.FirstName, '''', '')

or

DECLARE @name nvarchar(50) = 'ab''c'
SELECT REPLACE(@name,'''', '')

Upvotes: 2

Mansoor
Mansoor

Reputation: 4192

DECLARE @Str VARCHAR(100) = 'ab''c' SELECT REPLACE(@Str,'''', '')

Upvotes: 0

Related Questions