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
 Transact-SQL (2000)
 Excluding records with certain character in string

Author  Topic 

techrookie
Starting Member

6 Posts

Posted - 2005-09-09 : 18:48:34
I have the following simple query. However, I would like to omit all the records that contain a $ e.g. MGT-01-CORP$. How do I do this?

SELECT USERNAME
FROM EVENTS
WHERE USERNAME.....

Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-09-09 : 18:50:09
SELECT USERNAME
FROM EVENTS
WHERE USERNAME NOT LIKE '%$%'

You'll receive a performance penalty for this though.

Have a look at LIKE in SQL Server Books Online for details on what it can do.

Tara
Go to Top of Page

nosepicker
Constraint Violating Yak Guru

366 Posts

Posted - 2005-09-09 : 23:08:09
Also keep in mind that this will exclude any usernames that are NULL. You will have to decide how you want to handle the NULL values, if any.
Go to Top of Page
   

- Advertisement -