Solved

SQL 2005 SELECT Statement "NOT CONTAINS 'cat'"

Posted on 2007-11-28
3
1,201 Views
Last Modified: 2012-08-13
Here's the SQL statement I'm trying to execute!
SELECT       DISTINCT merchantCategory
FROM            dbo.Items
WHERE NOT CONTAINS 'cat'
In other words, I want it to cough up all the unique results for merchantCategory that don't contain the keyword 'cat'. I know the syntax is wrong somewhere around 'cat'; I'm just not sure what it is. Please help, Thanks, Chris.
0
Comment
Question by:jumpstart0321
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 400 total points
Comment Utility
SELECT   DISTINCT merchantCategory
FROM     dbo.Items
 WHERE merchantCategory NOT LIKE '%cat%'
0
 
LVL 9

Assisted Solution

by:CCongdon
CCongdon earned 100 total points
Comment Utility
Building from angellll's query, you might change the WHERE to read

WHERE merchantCategory NOT LIKE 'cat%'

if what you are looking for STARTS with the phrase 'cat' Othewise, you might block something that mereley has the phrase cat in the middle of it. Like the word 'scathing' -- sCAThing.
0
 

Author Comment

by:jumpstart0321
Comment Utility
Thanks guys:)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now