microsoft:microsoft_sql_server:sql:format:extract_integer_from_string
Microsoft - Microsoft SQL Server - SQL - Format - Extract Integer from String
CREATE FUNCTION extractInteger(@string VARCHAR(2000)) RETURNS VARCHAR(2000) AS BEGIN DECLARE @COUNT INT DECLARE @intNumbers VARCHAR(1000) SET @COUNT = 0 SET @intNumbers = '' WHILE @COUNT <= LEN(@string) BEGIN IF SUBSTRING(@string, @COUNT, 1)>='0' AND SUBSTRING (@string, @COUNT, 1) <='9' BEGIN SET @intNumbers = @intNumbers + SUBSTRING (@string, @COUNT, 1) END SET @COUNT = @COUNT + 1 END RETURN @intNumbers END GO
microsoft/microsoft_sql_server/sql/format/extract_integer_from_string.txt · Last modified: 2021/08/05 13:34 by peter