Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select Query

Author  Topic 

goodman2253
Yak Posting Veteran

88 Posts

Posted - 2013-09-08 : 01:29:59
Hello All,

I am using the select query as below
Select country from table1 which give the output as
COUNTRY
US
USA
UK
Malaysia
France
Europe
US
USA

I want to change whenever US comes it change to USA. So the output should be as below-:

COUNTRY
USA
USA
UK
Malaysia
France
Europe
USA
USA

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-09-08 : 02:10:03
select country=case when country='us' then 'usa' else country end from table1

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

goodman2253
Yak Posting Veteran

88 Posts

Posted - 2013-09-08 : 02:45:08
any function like regexp_replace. Because using case make the sql query execute very slow. For one case its fine, but If I have to use multiple then. I hope you understand my point
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-09-08 : 14:49:29
Case will not make this query run slow even if you add multiples. If you are having slowness on a particular query, then please post THAT query plus the indexes and execution plan.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -