cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Omit specific computers from Query

dwilkes
Engaged Sweeper
I have several of the reports which I would like to omit specific computers from. And do not want the Console to report them as well. I do not want to remove them completely just omit from certain reports and monitoring.

Is there a generic line of code that can be entered in each query, where I can add the computer name(s) to be omitted?

I am looking to augment the server and workstation reports of less than 1 GB on HDD, Computer not seen in 30 days, and Computer does not meet minimum requirements.

I did find an older post that pertained to only showing C: drives but the code in it did not work correctly.

Help on this is greatly appreciated.
Derek
4 REPLIES 4

JasonG
Engaged Sweeper
The statement needs to be placed at the end of the WHERE clause in the report definition (just before the ORDER BY clause).

dwilkes
Engaged Sweeper
I tried the query but was getting an error

"Invalid Select statement"
Unexpexted token "AND" at line .........

I did create the table with no problem.

What am I missing?
I entered the code at the end of the current script in the report builder. Just keep getting errors

JasonG
Engaged Sweeper
Create a new table in lansweeperdb called ExcludedMachines, with a single column to hold the Computername ID.

CREATE TABLE lansweeperdb.dbo.ExcludedMachines (Computername INT PRIMARY KEY);

Add the Computername ID of the machines which you want to exclude to the table.

You can now add a WHERE ... IN check to the reports in question. For example, for the web40repHDDFreeWorkstations (Workstations with less then 1GB free), add the following to the end of the WHERE clause:
AND lansweeperdb.dbo.tblComputers.Computername NOT IN (SELECT Computername FROM lansweeperdb.dbo.ExcludedMachines)


This will allow you to add machines to the excluded list without having to change every report in question.

Lansweeper
Lansweeper Former Employee
Lansweeper Former Employee
You could add an extra filter to the sql:

Where computer not like 'computername1' and computer not like 'computername2'