-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
CREATE ASSEMBLY StringUtil FROM 'C:\StringUtil.dll' WITH PERMISSION_SET = SAFE
GO
CREATE FUNCTION FindFirstNumber(@val NVARCHAR(1000))
RETURNS INTEGER
AS
EXTERNAL NAME StringUtil.[E.StringUtil].FindFirstNumber
GO
SELECT dbo.FindFirstNumber('1')
GO
SELECT dbo.FindFirstNumber('X2')
GO
SELECT dbo.FindFirstNumber('3X')
GO
SELECT dbo.FindFirstNumber('4X4')
GO
SELECT dbo.FindFirstNumber('X5X')
GO
SELECT dbo.FindFirstNumber('X6X7X')
GO
DROP FUNCTION FindFirstNumber
GO
DROP ASSEMBLY StringUtil
GO
