Character replacement in Sql Server tables

Asked

Viewed 152 times

0

I need to replace some strings in a database.

I’M TRYING WITH:

UPDATE dbo.ModeloMensagem
SET corpoMensagem = REPLACE(dbo.ModeloMensagem.corpoMensagem, '<', '[')
WHERE dbo.ModeloMensagem.corpoMensagem IN (SELECT DISTINCT(dbo.CampoTipoMensagem.nome) FROM dbo.CampoTipoMensagem);

UPDATE dbo.ModeloMensagem
SET corpoMensagem = REPLACE(dbo.ModeloMensagem.corpoMensagem, '>', ']')
WHERE dbo.ModeloMensagem.corpoMensagem IN (SELECT DISTINCT(dbo.CampoTipoMensagem.nome) FROM dbo.CampoTipoMensagem);


--DEPOIS ATUALIZA TABELA CampoTipoMensagem
UPDATE dbo.CampoTipoMensagem
SET nome = REPLACE(dbo.CampoTipoMensagem.nome, '<', '[');

UPDATE dbo.CampoTipoMensagem
SET nome = REPLACE(dbo.CampoTipoMensagem.nome, '>', ']');

Inside the table CampoTipoMensagem there are some tags ex:, etc...
But there are some HTML tags as well. I need to replace these tags from the example (there are more) with [CPF_CANDIDATO] (for example).

Someone here knows the solution to this?
If I rotate the replace, it will change even the HTML tags.

  • @Since I don’t understand, this update it is correctly replacing the tag < by [ ? Do you want q altere < by [CPF_CANDIDATO]? If yes, it would not be the case of Replace('<', '[CPF_CANDIDATO]') ?

  • I transfer the question to @Daniel Chagas :p

  • The messages look like this: <ID-CANDIDATE> (example). There are also some HTML tags in the message. That is, in the body fieldMensagem there is a message with A-Z characters, HTML tags and those of the example. I have to replace only the <> of the example messages. HTML tags have to continue...

  • Guys, problem solved... The solution did not fit here.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.