get integer vale
-
Saturday, March 02, 2013 9:20 AM
hi
I have this value
AS Printer 18558059431 R
I need 18558059431 this 11 digit number please help.
kindly help.- Edited by BI_group Saturday, March 02, 2013 11:09 AM
All Replies
-
Saturday, March 02, 2013 11:09 AM
thnaks
I have used
http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/.
- Proposed As Answer by Satheesh Variath Sunday, March 03, 2013 1:28 PM
-
Saturday, March 02, 2013 11:16 AM
declare @s nvarchar(200) = 'AS Printer 18558059431 R'
;WITH prepart AS (
SELECT substring(@s, patindex('%[0-9]%', @s), len(@s)) AS s
), postpart AS (
SELECT substring(s, 1, patindex('%[^0-9]%', s) - 1) AS s
FROM prepart
)
SELECT convert(bigint, s)
FROM postpart
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se- Proposed As Answer by Satheesh Variath Sunday, March 03, 2013 1:29 PM
- Marked As Answer by Kalman TothMicrosoft Community Contributor, Moderator Monday, March 11, 2013 12:52 AM

