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 2000 Forums
 SQL Server Development (2000)
 Select by text format

Author  Topic 

barefoot
Starting Member

2 Posts

Posted - 2006-02-15 : 04:08:12
Hi,

I have a query to built that selects or deletes the record if the storage column does not hold the text data in this format ??-???-? (eg. FA-999-L).

Any idea of how to select the data like dat? Any SQL syntax that governs such function?

Thanks.



Kristen
Test

22859 Posts

Posted - 2006-02-15 : 04:18:01
Somthing like this?

SELECT *
-- DELETE D
FROM MyTable AS D
WHERE MyColumn NOT LIKE '__-___-_'

The SELECT will show you which rows are going to be delete, remove that and enable the DELETE when you are ready to delete them

The '_' character will match any single character. If the code you need must be Alpha-Alpha-HYPHEN-Digit-Digit-Digit-HYPHEN-Alpha, specifically, then you could make a more robust test with

WHERE MyColumn NOT LIKE '[A-Z][A-Z]-[0-9][0-9][0-9]-[A-Z]'

Kristen
Go to Top of Page

barefoot
Starting Member

2 Posts

Posted - 2006-02-20 : 04:23:48
Thanks Kristen. It really works. Really appreciate the help. Gonna continue developing the rest of the DTS after this. :)
Go to Top of Page
   

- Advertisement -