1

I couldnt find a clear answer to this questions, should be a simple one. Basically I am trying to get all computers that dont have word installed. This query seems to be giving me wrong data. Any ideas? Thanks!

 SELECT DISTINCT Name FROM dbo.vComputer AS v WHERE Name NOT IN ( SELECT Name FROM dbo.vComputer WHERE (dbo.vComputer.installedsoftware LIKE N'%word%'))) 
7
  • 1
    What's wrong about it? Are there other strings in installedsoftware that contain word? Commented Jan 31, 2014 at 14:58
  • You could just use NOT LIKE and drop the subselect. Commented Jan 31, 2014 at 14:58
  • 2
    Is the field dbo.vComputer.installedsoftware is nullable? Commented Jan 31, 2014 at 14:59
  • 1
    So we don't know what the data in your table looks like, we don't know what data you expect to get from your query, and we don't know what wrong data you're getting instead, and you expect help? Sure, why not. Commented Jan 31, 2014 at 15:00
  • 1
    Provide sample data and expected results. Your query cannot be understood out of context. Commented Jan 31, 2014 at 15:03

1 Answer 1

2

Try like this

With NOT EXISTS

SELECT Name FROM dbo.vComputer AS V WHERE NOT EXISTS ( SELECT Name FROM dbo.vComputer AS S WHERE S.installedsoftware LIKE N'%word%' ) 

WITH NOT IN

SELECT Name FROM dbo.vComputer AS V WHERE Name NOT In (SELECT Name FROM dbo.vComputer AS S WHERE S.installedsoftware LIKE N'%word%' ); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.