Here is the Solution how you can replace Character or Word in SQL QUERY itself.
Query:
SELECT REGCODE, REGTYPE, TRANSLATE(REGTYPE,'R','K') AS RESULT1, REPLACE(REPLACE(REGTYPE,'R4','FOUR'),'R5','FIVE') AS RESULT2 FROM REGION
GO
Here in output REPLACE column will be displayed in which as per required we can replace our desired value in column depending on value of particular column.
OUTPUT
Query:
SELECT REGCODE, REGTYPE, TRANSLATE(REGTYPE,'R','K') AS RESULT1, REPLACE(REPLACE(REGTYPE,'R4','FOUR'),'R5','FIVE') AS RESULT2 FROM REGION
GO
Here in output REPLACE column will be displayed in which as per required we can replace our desired value in column depending on value of particular column.
REGCODE | REGTYPE | RESULT1 | RESULT2 |
1 | R4 | K4 | FOUR |
1 | R5 | K5 | FIVE |
No comments:
Post a Comment