I'm trying to remove certain characters.
At the moment I have output like cityname district
but I want to remove cityname
.
SELECT Ort FROM dbo.tblOrtsteileGeo
WHERE GKZ = '06440004'
Output:
Büdingen Aulendiebach
Büdingen Büches
Büdingen Calbach
Büdingen Diebach
Büdingen Dudenrod
Büdingen Düdelsheim
Desired output:
Aulendiebach
Büches
Calbach
Diebach
Dudenrod
Düdelsheim
This question is related to
sql-server
tsql
One issue with REPLACE
will be where city names contain the district name. You can use something like.
SELECT SUBSTRING(O.Ort, LEN(C.CityName) + 2, 8000)
FROM dbo.tblOrtsteileGeo O
JOIN dbo.Cities C
ON C.foo = O.foo
WHERE O.GKZ = '06440004'
UPDATE yourtable
SET field_or_column =REPLACE ('current string','findpattern', 'replacepattern')
WHERE 1
Source: Stackoverflow.com