标签: sql sql-server-2008 sql-server-2012 sql-server-2008-r2
我有这样的文字“running hl loan hdfc 9.5% customer is not interested” 我想从整个字符串中仅选择9.5%。无论是什么字符串,但我想只选择%值。
running hl loan hdfc 9.5% customer is not interested
9.5%
答案 0 :(得分:0)
在SQL-Server中,您可以使用SUBSTRING,PATINDEX和CHARINDEX:
declare @str as varchar(155) set @str = 'running hl loan hdfc 8569.5% customer is not interested' select SUBSTRING(@str, PATINDEX('%[0-9]%', @str), CHARINDEX('%', @str) - PATINDEX('%[0-9]%', @str) + 1)