SELECT dbo.fnc_AllowNumbersOnly('ST-3')
returns 3
Scott Williams,
2008-06-25 (first published: 2008-05-20)
SELECT dbo.fnc_AllowNumbersOnly('ST-3')
returns 3
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- SELECT dbo.fnc_AllowNumbersOnly('ST-3') CREATE FUNCTION [dbo].[fnc_AllowNumbersOnly]( @string NVARCHAR(60) ) RETURNS NVARCHAR(60) AS BEGIN -- Strip @number of extra chracters DECLARE @lenPhone INT ,@phoneStr NVARCHAR(30) WHILE PATINDEX('%[^0-9]%', @string) > 0 SET @string = REPLACE(@string, SUBSTRING(@string,PATINDEX('%[^0-9]%', @string),1),'') -- Returns Value RETURN @string END
Inline Table Valued Functions (iTVFs) are one type of user defined function that is available to implement in SQL Server since SQL Server 2000.
iTVFs remain a very useful tool in our SQL armoury, so let's quickly revisit them and the different ways we can use them in our code.
2020-10-07 (first published: 2020-09-08)
30,466 reads
SQL Server MVP Jeff Moden walks us through the classic problem of finding all the "Active" rows for the previous month using start and end dates. This is excellent for those new to T-SQL.
2010-01-11
9,878 reads