我有这样的数据:
string 1: 003Preliminary Examination Plan string 2: Coordination005 string 3: Balance1000sheet
我期望的结果是
string 1: 003 string 2: 005 string 3: 1000
我想用sql实现它。
vd2z7a6w16#
查询:
DECLARE @temp TABLE ( string NVARCHAR(50) ) INSERT INTO @temp (string) VALUES ('003Preliminary Examination Plan'), ('Coordination005'), ('Balance1000sheet') SELECT SUBSTRING(string, PATINDEX('%[0-9]%', string), PATINDEX('%[0-9][^0-9]%', string + 't') - PATINDEX('%[0-9]%', string) + 1) AS Number FROM @temp
k75qkfdt17#
试试这个-查询:
DECLARE @temp TABLE ( string NVARCHAR(50) ) INSERT INTO @temp (string) VALUES ('003Preliminary Examination Plan'), ('Coordination005'), ('Balance1000sheet') SELECT LEFT(subsrt, PATINDEX('%[^0-9]%', subsrt + 't') - 1) FROM ( SELECT subsrt = SUBSTRING(string, pos, LEN(string)) FROM ( SELECT string, pos = PATINDEX('%[0-9]%', string) FROM @temp ) d ) t
输出:
---------- 003 005 1000
17条答案
按热度按时间vd2z7a6w16#
查询:
k75qkfdt17#
试试这个-
查询:
输出: