Abaixo colocarei uma função que você possa extrair apenas números de uma string:
CREATE FUNCTION Fn_extrairnumero(@String VARCHAR(2000)) RETURNS VARCHAR(1000) AS BEGIN DECLARE @Count INT DECLARE @IntNumeros VARCHAR(1000) SET @Count = 0 SET @IntNumeros = '' WHILE @Count <= Len(@String) BEGIN IF Substring(@String, @Count, 1) >= '0' AND Substring(@String, @Count, 1) <= '9' BEGIN SET @IntNumeros = @IntNumeros + Substring(@String, @Count, 1) END SET @Count = @Count + 1 END RETURN @IntNumeros END go
Após criar a função você pode testar usando o seguinte código.
SELECT dbo.Fn_extrairnumero('Meu Endereço é Av. Paulista Nº 7, CEP 00.777-13') GO
Provavelmente aparecerá o seguinte resultado:
70077713
Port video games have actually long been a popular type of entertainment, providing exhilarating gameplay…
When it pertains to online gambling, safety needs to be a top issue for every…
There are many reasons to play no-cost online casino games in the coming year. The…
On the internet casinos have acquired tremendous appeal in recent times, offering gamers with the…
Welcome to our useful post concerning the very best casino site game! Whether you're a…
The random number generator (or RNG) is the program that generates the outcome of every…