Book a Demo

Author Topic: sql Replace  (Read 3513 times)

GrahamL

  • EA User
  • **
  • Posts: 111
  • Karma: +2/-0
    • View Profile
sql Replace
« on: March 12, 2021, 10:18:07 pm »
Hi
I am trying to develop an SQL script using the REPLACE function and do not seem to be able to get the syntax correct

SELECT t_object.Alias As Alias, t_object.Name As Name, t_object.Note As notes
From t_object
REPALACE ("",'%!!!%', '%????%')
Where t_object.Object_Type = 'Requirement' And t_object.Note LIKE '%!!!%'

The current error is Column name is missing

Can someone please show me the correct syntax

Thanks

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: sql Replace
« Reply #1 on: March 12, 2021, 10:43:25 pm »
You can use that like this:

Code: [Select]
select replace (o.Name, 'A', 'B')
from t_object o

If you have a object name 'Asomething', the query will return 'Bsomething'

But this is a select query, so it won't change anything in the database.

If you actually want to change the database you need an update query. (which isn't accepted by Repository.SQLQuery)

Geert