Solved

Replace

Posted on 2011-03-25
8
259 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
 
LVL 32

Expert Comment

by:ewangoya
ID: 35220059


update table
set tag_col = 'PRI'
where tag_col = 'ISDN'
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Log Backup 2 21
Upgrading Integration Services 3 28
the whoisactive update 12 39
Upgrading an old legacy SQL server 20082 to 2014 - TSQL compatibility 3 37
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…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now