0

Suppose a table ABC have column XYZ containing data

3PSY0001-06-08-F
3PSY0001A-07-09-P
3PSY0001-02-09-P
3PSY0001-07-07-F
3PSY0002-09-08-P
3PSY0002A-01-03-P
3PSY0002-07-07-F

How can i write a query so that the data ending with P without A can be updated with A.

For example, with that query, data

3PSY0001-02-09-P AND 3PSY0002-09-08-P will be updated as

3PSY0001A-02-09-P AND 3PSY0002A-09-08-P while the other data remains the same.

Please Help.

Warm Regards

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Wakhal
0
update ABC
  set XYZ = left(XYZ, 8) + 'A' + substring(XYZ, 9, 1000)
  where XYZ like '%P' and XYZ not like '%A%'
0

Hi Huangzhi,

Works like a charm. You are a life saver. Thanks a lot.

Warm Regards

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.