Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pattern matching

Status
Not open for further replies.

sedgely

Technical User
Feb 21, 2002
406
GB
i'm tearing my hair out with this one...
i need to return all rows where col1 matches the following pattern: 4 numbers followed by hyphen followed by 4 numbers.
e.g. '0000-1200' or '0800-1600'
i know this should be fairly straight forward using patindex but i can't get it.

Cheers, Craig
Si fractum non sit, noli id reficere
 
Code:
SELECT ...
FROM ...
WHERE Col1 LIKE '[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'
not tested

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top