【发布时间】:2021-04-01 19:47:24
【问题描述】:
我正在尝试从具有 4 个或更多连续整数的记录中提取数字以用作另一个表的参考。
到目前为止,我已经尝试过使用PATINDEX,但它并没有真正按照我需要的方式工作。如果有记录包含一组以上的序列号,那么我需要它只提取第一个。
我尝试过的:
SELECT SUBSTRING(nvt.AdditionalInformation, PATINDEX('%[0-9]%', nvt.AdditionalInformation), LEN(nvt.AdditionalInformation))
FROM dbo.NSReportVtest nvt;
SELECT PATINDEX('%[0-9]%', nvt.AdditionalInformation) AddtionalInformation
FROM dbo.NSReportVersionsTest nvt
表格中的数据:
| Column 1 |
|---|
| Added the COB 1.1 & COB 5 Learning types to the report. |
| Added the previous agreement year and previous agreement final score fields to the report. |
| Demo Certificate TP35356 |
| TP45905, TP46379, TP44804, TP46432 - Added HasTalentAssessment, AssessmentDate, AssessmentCompleted, PMScore, ValueSurveyScore, OverallPMSCore, Drivers Licence |
| TP38298 - Removed the Sales Support and Customer Service Consultant - CIC job titles from the report. |
预期结果:
| Column 2 |
|---|
| 35356 |
| 45905 |
| 38298 |
【问题讨论】:
标签: sql sql-server tsql substring sql-server-2014