Replace

Hi all,

Please find the attachment,

I have a requirement where I need to replace the ISDN values into PRI from the Tag Column
I guess we have something like this select replace([tag_col],'ISDN','PRI') from tablename. this works fine.

I have another requirement where rest of the values in the tag_col should go null/blank.
It means I should have tag_col with 'PRI'  only.

please help out.
thanks in adv
test.xlsx
parpaaAsked:
Who is Participating?
 
RGBDartConnect With a Mentor Commented:
first queries written by ewangoya and parpaa will replace values in tag_col column from ISDN to PRI. All the other row (not ISDN) will remain unchanged.

the last one will set tag_col  = null for all records that are not PRI and not ISDN
0
 
RGBDartCommented:
just add

where replace([tag_col],'ISDN','PRI') = 'PRI'
0
 
RGBDartCommented:
[telepathy mode = on]
May be you want update items in that table, not select from it?
[telepathy mode = off]
If yes, query will be different
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
parpaaAuthor Commented:

@RGB many thanks for your sugg,
What if I want to update the table?? how the query will be?
0
 
Ephraim WangoyaCommented:


update table
set tag_col = 'PRI'
where tag_col = 'ISDN'
0
 
parpaaAuthor Commented:
UPDATE TABLE
SET TAG_COL ='PRI'
WHERE TAG_COL='ISDN'

what if I want rest of the records in the TAG_COL column be null ?
0
 
Ephraim WangoyaConnect With a Mentor Commented:
Update table
Set tag_col =null
Where tag_col <> 'PRI' and tag_col <> 'ISDN'
0
 
parpaaAuthor Commented:
Highly appreciated for your efforts and suggestions. Thank you so much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.