May 16, 2012 at 8:16 am
I need to return all part numbers in a table that are based on the following pattern:
8675G309
The fist four characters are numeric, the fith alpha, and the remaining two are numeric.
How would I go about finding these? Any help will be greatly appreciated.
May 16, 2012 at 8:25 am
Use LIKE
SELECT ..
FROM mytable
WHERE PartNumber LIKE '[0-9][0-9][0-9][0-9][A-Za-z][0-9][0-9]'
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537May 16, 2012 at 8:28 am
Worked like a charm! Thanks.
May 16, 2012 at 9:03 am
Mark-101232 (5/16/2012)
Use LIKE
SELECT ..
FROM mytable
WHERE PartNumber LIKE '[0-9][0-9][0-9][0-9][A-Za-z][0-9][0-9]'
If your collation is case-insensitive (default ), you don't need to specify both A-Z and a-z.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
May 16, 2012 at 10:39 am
Good to know. Thanks again.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply