How to get the numeric part from a string using T-SQL?

后端 未结 4 1323
天命终不由人
天命终不由人 2020-11-30 09:56

I have the following string.

Input
--------------
2030031469-NAI 

To get the numeric part, I am using the following script

         


        
4条回答
  •  悲&欢浪女
    2020-11-30 10:26

    In case your string start with alphabet and end with number like ERT-123

    you can use this query:

     (select  substring(@str,patindex('%[0-9]%', @str),len(@str)))
    

提交回复
热议问题