Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****** Object: UserDefinedFunction [dbo].[udf_GetNumeric] Script Date: 1/17/2018 3:54:02 PM ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE FUNCTION [dbo].[udf_GetNumeric]
- (@strAlphaNumeric VARCHAR(256))
- RETURNS VARCHAR(256)
- AS
- BEGIN
- DECLARE @intAlpha INT
- SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric)
- BEGIN
- WHILE @intAlpha > 0
- BEGIN
- SET @strAlphaNumeric = STUFF(@strAlphaNumeric, @intAlpha, 1, '' )
- SET @intAlpha = PATINDEX('%[^0-9]%', @strAlphaNumeric )
- END
- END
- RETURN ISNULL(@strAlphaNumeric,0)
- END
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement