My Technical Notes

Monday, 15 April 2013

Retrieving Number from Concatenated String and Number

Let's say that you have strings of the form [Letters][Number] and you only want the [Number] portion. We can use the following SQL:


SELECT 
    SubKPICategoryId,
    SUBSTRING(SubKPICategoryId, PATINDEX('%[0-9]%', SubKPICategoryId), LEN(SubKPICategoryId)) AS computed 
from dbo.kpi1 

TODO: rewrite this post to remove col names

No comments: