USE [Northwind]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[AnyNum](@zs nvarchar(1024))
RETURNS varchar(30)
AS
BEGIN
declare @i int,@offset int
set @offset=patindex('%[0-9]%',@zs)
if @offset>0
begin
set @i=1
while 1=1
begin
if isnumeric(substring(@zs,@offset+@i,1))=0 break
set @i=@i+1
end
end
return substring(@zs,@offset,@i)
END