Atal Atmar
Atal Atmar

Reputation: 9

REPLACE function for replacing part of string in specific column

I have written the following code:

SELECT * 
FROM BMD_MI_OPS.DBH_TELEFONIE
WHERE cast(DATUM_TIJD as date) BETWEEN 1180212 AND 1180217;

UPDATE BMD_MI_OPS.DBH_TELEFONIE 
SET QUEUE_NAAM = REPLACE(QUEUE_NAAM, '_DVB', '');

This should take all columns of the table BMD_MI_OPS.DBH_TELEFONIE within the given period in the WHERE statement. Then it should erase every _DVB that appears in the column QUEUE_NAAM. For example, VQ_PAR_EC_00_DVB should become VQ_PAR_EC_00.

I guess I am doing something wrong, any help on how to get this done would be appreciated.

Thanks in advance.

Upvotes: 1

Views: 210

Answers (1)

Arnaud Peralta
Arnaud Peralta

Reputation: 1305

Your statements are not linked, if you want to update your data you need to add a WHERE clause in your UPDATE

For example :

UPDATE BMD_MI_OPS.DBH_TELEFONIE 
SET QUEUE_NAAM = REPLACE(QUEUE_NAAM, '_DVB', '')
WHERE CAST(DATUM_TIJD AS DATE) BETWEEN 1180212 AND 1180217;

Selecting rows before your update has no impact on your update, it' just a SELECT

Upvotes: 2

Related Questions