SQL Server STRING Functions
SQL Server STRING Functions is a SQL function in the SQL Server Specific category. SQL Server string search and manipulation functions for text processing. The syntax is CHARINDEX(), PATINDEX(), LEFT(), RIGHT(), SUBSTRING(), REPLACE(). It accepts see syntax. It returns string operation result. A typical example: -- CHARINDEX: find position of substring SELECT CHARINDEX('World', 'Hello World'); -- 7 -- PATINDEX: find position using pattern SELECT PATINDEX('%[0-9]%', 'Order123'); -- 6 (first digit) -- SUBSTRING with CHARINDEX: SELECT SUBSTRING(email, CHARINDEX('@', email) + 1, LEN(email)) AS domain FROM users; -- 'alice@company.com' -> 'company.com' -- REPLACE with nested calls: SELECT REPLACE(REPLACE(phone, '(', ''), ')', '') AS clean_phone FROM contacts; -- '(555) 123-4567' -> '555 123-4567' -- LEFT / RIGHT: SELECT… A close relative is OUTPUT Clause, which sQL Server: returns values from DML statements (like PostgreSQL RETURNING). A close relative is STUFF(), which sQL Server: deletes a specified length of characters from a string and inserts another string at the start position.