Click to See Complete Forum and Search --> : [RESOLVED] Using replace function


nrana
03-23-2010, 12:28 PM
I am using sql server 2005 and this is my problem:

i have a variable defined as nVarchar
e.g. @name = nVarchar (1000)

single quotes can be inserted into that variable as values

e.g. sandra's world

is there a way to use a replace function so when i select that variable i can replace that single quote with space?

e.g.
declare @name nVARCHAR(1000)
set @name ='sandra''s world'
right now when i select @name it pulls as : sandra's world
how do i select @name so it pulls as : sandra s world

your help is highly appreciated.

Thanks.

nrana
03-23-2010, 01:09 PM
Nevermind ... i found it in diff website.
Thank you .. here is the solution.

declare @name nVARCHAR(1000)
DECLARE @SQL_Select nVARCHAR(max)
set @name='hello'''s'

set @SQL_Select = @name

print @sql_select
SET @sql_select = REPLACE(@sql_select, '''',' ')
print @sql_select