I have a simple table with the following columns
PrinterModel
: Model of the printer.
PrinterName
: Name of printer as it appears on the users computer.
PortName
: Usually an IP, UNC path or USB.
MachName
:Computer that printer was found on.
I have created the following query
SELECT PrinterModel, PrinterName, PortName
FROM [ksubscribers].[dbo].[vCurrPrinterInfo]
WHERE PrinterModel NOT LIKE '%Microsoft%'
AND PrinterModel NOT LIKE '%PDF%'
AND PrinterModel NOT LIKE '%HP ePrint%'
AND PrinterModel NOT LIKE '%Snagit%'
AND PrinterModel NOT LIKE '%Nuance%'
AND PrinterModel NOT LIKE '%Amyuni%'
AND PrinterModel NOT LIKE '%Foxit%'
AND PrinterModel NOT LIKE '%Brother PC-FAX%'
AND PrinterModel NOT LIKE '%Remote Desktop%'
AND PrinterModel NOT LIKE '%Wondershare%'
ORDER BY PortName
The table is basically a collection of printers installed on various computers within an organisation. As the same printer can be installed on multiple computers (think network printer) the table is full of duplicates. We can use the PortName to identify duplicates, however, some rows will show a slight variation in PortName e.g. 10.0.0.200 and 10.0.0.200_1.
Is it possible to compare data in each row focusing only on the data in the PortName column and if the data is similar e.g. 10.0.0.200 vs 10.0.0.200_1 return a single row result?
Here is an example of the table
Model | Name | Port
OKI MC560 (POS) | OKI MC560 Try 1 | 10.0.0.200
OKI MC560 (PCL) | OKI MC560 Try 2 | 10.0.0.200
OKI MC560 (PCL) | OKI MC560 Try 3 | 10.0.0.200_1
OKI MC560 (TST) | OKI MC560 Try 1 | 10.0.0.200
...and ideally I would return
OKI MC560 (POS) | OKI MC560 Try 1 | 10.0.0.200
I am not too fussed which rows PrinterModel/Printer Name is returned as long as we end up with just one result it could be from any row.
I have reviewed a similar question here SQL compare data from two tables however I can't see how they are comparing the text string using the difference command?
Have attached a screen shot of the current query along with the data returned. Any advise would be greatly appreciated.