How to get a substring from a formatted string

前端 未结 3 1106
面向向阳花
面向向阳花 2021-01-29 09:57

I would like to get a substring 403162 from the given string Praveen(403162) in sql?

3条回答
  •  星月不相逢
    2021-01-29 10:55

    Declare @Name VARCHAR(100)
    
    Select @Name = 'Praveen(403162)'
    
    Select @Name = SUBSTRING(@name,PATINDEX('%[0-9]%',@Name),LEN(@Name))
    Select SUBSTRING (@Name,1,6) 
    

提交回复
热议问题