Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
collie
Constraint Violating Yak Guru
400 Posts |
Posted - 2010-09-09 : 11:41:24
|
Hi,I need to get 13499005890 in the string below. The string can vary in length.declare @w nvarchar (600)set @w='invoice number: 13499005890 Customer:homer simpsom limited'Not sure how to get the number. Appreciate any assistance.ThanksWhisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much. |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-09-09 : 11:59:24
|
SELECT SUBSTRING(@w, PATINDEX('%[0-9]%', @w), CHARINDEX(' ', @w, PATINDEX('%[0-9]%', @w))-PATINDEX('%[0-9]%', @w) )This assumes you want the first string of numbers up to but not including the next space character. If there are different criteria please post them. |
 |
|
collie
Constraint Violating Yak Guru
400 Posts |
Posted - 2010-09-09 : 12:24:09
|
Thanks.Works :)Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much. |
 |
|
|
|
|