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 2005 Forums
 Transact-SQL (2005)
 How to replace() multiple strings at once?

Author  Topic 

lopes_andre
Starting Member

12 Posts

Posted - 2009-12-21 : 11:18:21
Hi,

I need to replace multiple strings at once using the REPLACE function.

I have a HTML like this:

<p>Informamos que o período de avaliação de projectos termina já no próximo dia @data_fim@.</p>

<p>Agradecemos que preencha as seguintes avaliações:<br />
@projectos_a_avaliar@</p>

<p>Para mais esclarecimentos, contacte o Departamento de Recursos Humanos.</p>


And I need to replace the tags "@data_fim@" and "@projectos_a_avaliar@".

I know the value of the tags doing one simple select like this:
select @vDATA_FIM = data_fim, @vPROJECTOS_A_AVALIAR
from projectos
where id_company = 'x' and id_empl = 'x111' and


I'am trying to do something like this to replace:

select @mail_subject = mail_subject,  

@mail_body = replace(mail_body,'@projectos_a_avaliar@', substring(@pID_PROJECTO,1,CHARINDEX('.',@pID_PROJECTO)-1)+'747'+' - '+@vNOME_PROJECTO)

from m4_msg_alertas

where id_tipo_alerta = @vOP


My question... I need to replace "@projectos_a_avaliar@" and "@data_fim@" at once. How can I do this?


Best Regards,

DP978
Constraint Violating Yak Guru

269 Posts

Posted - 2009-12-21 : 11:23:10
Can you imbed them?

Like:

Declare @mystring Varchar(100)

Set @mystring = 'This is my sentance.'

Select Replace(Replace(@Mystring, 'is', '#'),'my','@')
Go to Top of Page
   

- Advertisement -