Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and Replace string

Status
Not open for further replies.

Raul2005

Programmer
Sep 23, 2005
44
0
0
US
Any help will be appreciated

ID text
1 RTS_US SalesCov for HGU_SEC
2 GRT_UK SalesCov for All Euro
3 JJJ_US SalesCov for All Euro
4 COM_US SalesCov for HGU_SEC

From the previous record I need an output like this
I need to create an additional colum CODE and the value has to be related with the value in text..Example
The new query should look for " GRT_UK SalesCov for All Euro " if All Euro Is found the new column CODE Should contain EU....
ID text CODE
1 RTS_US SalesCov for HGU_SEC HG
2 GRT_UK SalesCov for All Euro EU
3 JJJ_US SalesCov for All Euro EU
4 COM_US SalesCov for HGU_SEC HG


Thanks

 
alter table x
add Code varchar(2)

update x
set code = case when text like '%all euro' then 'EU'
when text like '%HGU_SEC' then HG'
end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top