Solved

Replace

Posted on 2011-03-25
8
260 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:parpaa
  • 3
  • 3
  • 2
8 Comments
 
LVL 4

Expert Comment

by:RGBDart
ID: 35214171
just add

where replace([tag_col],'ISDN','PRI') = 'PRI'
0
 
LVL 4

Expert Comment

by:RGBDart
ID: 35214182
[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
 

Author Comment

by:parpaa
ID: 35216374

@RGB many thanks for your sugg,
What if I want to update the table?? how the query will be?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 32

Expert Comment

by:ewangoya
ID: 35220059


update table
set tag_col = 'PRI'
where tag_col = 'ISDN'
0
 

Author Comment

by:parpaa
ID: 35221546
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
 
LVL 32

Assisted Solution

by:ewangoya
ewangoya earned 200 total points
ID: 35221869
Update table
Set tag_col =null
Where tag_col <> 'PRI' and tag_col <> 'ISDN'
0
 
LVL 4

Accepted Solution

by:
RGBDart earned 300 total points
ID: 35222234
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
 

Author Closing Comment

by:parpaa
ID: 35223005
Highly appreciated for your efforts and suggestions. Thank you so much.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question