REPLACE (Azure Stream Analytics)
Zamienia wszystkie wystąpienia określonej wartości ciągu na inną wartość ciągu.
Składnia
REPLACE ( stringExpression, stringPattern, stringReplacement )
Argumenty
stringExpression
Wyrażenie ciągu do wyszukania.
stringPattern
Znaleziono podciąg. Jeśli ciąg StringPattern jest pustym ciągiem, zwracany jest ciąg stringExpression .
stringReplacement
Ciąg zastępujący.
Typy zwracane
Zwraca wartość NULL, jeśli którykolwiek z argumentów ma wartość NULL. W przeciwnym razie zwraca wartość nvarchar(max).
Przykłady
SELECT REPLACE(value, pattern, replacement) AS result FROM input
Wyrażenie | Wynik |
---|---|
REPLACE('abcde', 'cd', 'xx') | "abxxe" |
REPLACE('cdabcd', 'cd', 'x') | "xabx" |
REPLACE('cd', 'cd', 'xxx') | "xxx" |
REPLACE('abcde', 'gh', 'xx') | "abcde" |
REPLACE('abcde', 'cde', '') | "ab" |
REPLACE('abcde', '', 'xxx') | "abcde" |
REPLACE('', 'cde', 'xxx') | '' |
REPLACE(NULL, 'cde', 'xxx') | null |
REPLACE('abcde', NULL, 'xxx') | null |
REPLACE('abcde', 'cde', NULL) | null |