Dica com T-SQL: REPLACE()

Fala pessoal, tudo bem com vocês?

Espero que sim, vamos para mais uma dica com T-SQL.

Segue simples exemplo usando o comando REPLACE.

Serve para substituir um determinado argumento por outro, de forma bem simples, é muito usado no dia a dia.

O exemplo a seguir, vamos exibir a coluna Nome do Aluno contendo ponto(.) entre o nome e o sobrenome do Aluno, veja:

Captura de tela mostrando resultados de uma consulta SQL com a coluna 'NomeStudents'. As entradas incluem nomes separados por pontos, como 'Pedro.Silva', 'Vanessa.Santos', 'João.Paulo' e 'Maria.Aparecida'.

Agora vamos aplicar REPLACE para substituir o ponto(.) por espaço entre o nome e sobrenome, veja o resultado.

Screenshot of a SQL Server Management Studio query window displaying the successful execution of a T-SQL command that replaces dots with spaces in student names.

Muito bom, agora temos o nome e sobrenome separados por espaço e não mais por ponto(.).

Bacana né?

Espero ter ajudado com essa simples contribuição.

Desejo a todos uma ótima semana, um grande abraço e até o próximo post pessoal!

Felippe Santos

T-SQL: REPLACE()

Hi Guys, how are you doing?
I hope you are doing well! And let’s take a look at one more tip.

Fallow simple example about command T-SQL REPLACE

It is used to substitute a argument for another argument the simple way and it is using everyday in many queries.

This example to show the column NameStudents containing dot(.) between name and last name of Student, look:

Exibição da coluna NameStudents em uma consulta SQL, mostrando nomes de alunos com ponto entre primeiro e último nomes.

Now we go apply the command REPLACE to substitute dot(.) for space between Name and Last Name, look the result:

Screenshot of a SQL Server Management Studio query window displaying a T-SQL command using the REPLACE function to process student names.

Very well, now we have Name and Last Name separeted for space and not more for dot(.).

That’s cool, isn’t it?

I hope I helped you with this simple contribution.

I wish you all have a great week, warm hugs and I´ll see you on our next post guys.
Santos, Felippe