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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 search for a specific text format

Author  Topic 

jql
Starting Member

30 Posts

Posted - 2011-11-16 : 04:16:58
Can someone please help me with the following problem.
Each product has a batch id that should be AHPVA0 , two numbers and then two more letters (e.g. AHPVA082CD), however staff have not been inputting these correctly.
I need to be able to search the batchid field for all codes that are not in the format above.
Your help is greatly appreciated as I am stuck.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-11-16 : 04:23:33
select * from tbl where batchid not like 'AHPVA0[0-9][0-9][A-Z][A-Z]'


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jql
Starting Member

30 Posts

Posted - 2011-11-16 : 04:28:46
Brillant, thank you.
Have been trying to find the answer for over 2hrs this morning
Go to Top of Page
   

- Advertisement -