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)
 String manipulation

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-08-10 : 08:14:28
Robert writes "I am trying to use a user defined function where I search for double quotes (") and replace with a space. I am trying to use LEFT and RIGHT functions in conjunction with patindex and LEN. However it seems that LEN(string) stops counting when it finds double quotes. Can you give me some insight? Help, please.

Example:

create function Remove_Quotes(@Str char(100))
returns char(100)
As
begin
if @Str <> ''
Begin
while(patindex('%"%',@Str)<>0)
set @Str = left(@Str,patindex('%"%',@Str)-1)+' '+ right(@Str,len(@Str)-patindex('%"%',@Str))
end
return(@Str)
end"
   

- Advertisement -