Logo
You
Code

Extract numbers or characters from a string MSSQL

Autor YouCode - http://www.youcode.com.ar/sql-server/extract-numbers-or-characters-from-a-string-mssql-482

Separate the numbers and letters of a text string - Sql Server

Extract only numbers
select 
SUBSTRING(My_field, PATINDEX('%[0-9]%', My_field), PATINDEX('%[0-9][^0-9]%', My_field + 't') - PATINDEX('%[0-9]%',My_field) + 1) AS Number
from my_table
Extract only character a-Z
select 
SUBSTRING(My_field, PATINDEX('%[a-Z]%', My_field), PATINDEX('%[a-Z][^a-Z]%', My_field+ 't') - PATINDEX('%[a-Z]%',My_field) + 1) AS letters
from My_Table
http://www.youcode.com.ar/sql-server/extract-numbers-or-characters-from-a-string-mssql-482