Skip to content
Advertisement

How to replace Feature Name have Unit word by Unit Only After as Keyword?

I work with SQL Server 2012 and face an issue: I can’t replace Features contain Unit word to be Unit only.

So this code returns

while I need it to be

Meaning word after as keyword if it contains Unit, then it should be Unit only.

Change will be after the AS keyword.

Expected result is to replace all words that contain Unit with just Unit only, so the output should be:

Advertisement

Answer

Using CASE expression:

For quoting identifiers is safer to use QUOTENAME function instead of adding []

db<>fiddle demo

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement