Tricket, der virker, er at SAMLEDE din værdi til Latin1_General_BIN før du bruger REPLACE, og brug også nchar(0x00) COLLATE Latin1_General_BIN for string_pattern .
REPLACE ( string_expression , string_pattern , string_replacement )
select
[Terminated] = N'123' + nchar(0) + N'567'
,[Replaced with -] = REPLACE((N'123' + nchar(0) + N'567') COLLATE Latin1_General_BIN
, nchar(0x00) COLLATE Latin1_General_BIN
,'-')
,[Removed] = REPLACE((N'123' + nchar(0) + N'567') COLLATE Latin1_General_BIN
, nchar(0x00) COLLATE Latin1_General_BIN
,'')
Her er resultatet (brug Output til tekst):
Contains Replaced with - Removed
---------- ----------------- --------
123 567 123-567 123567