The Community is now in read-only mode to prepare for the launch of the new Flexera Community. During this time, you will be unable to register, log in, or access customer resources. Click here for more information.

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

SQL Query for obtaining the application deployed list

flexeranoob
By
Level 7

We are looking for a query to obtain the following information from the database directly

  1. Hostname
  2. IP Address
  3. Application Name
  4. Application Version
  5. Last inventory date

I know this is broad, but can you please help me with the query for this?

(1) Solution

mfranz
By Level 17 Champion
Level 17 Champion

Application version should be part of the FullName attribute. If you want distinct fields for version, edition, etc. the query would include additional tables:

SELECT
cc.ComputerName AS 'Hostname',
cc.IPAddress,
stpub.PublisherName,
stp.ProductName,
stv.VersionName,
ste.EditionName,
cc.InventoryDate
FROM InstalledApplications ia
JOIN ComplianceComputer cc ON cc.ComplianceComputerID = ia.ComplianceComputerID
JOIN SoftwareTitle st ON st.SoftwareTitleID = ia.SoftwareTitleID
JOIN SoftwareTitleProduct stp ON st.SoftwareTitleProductID = stp.SoftwareTitleProductID
JOIN SoftwareTitlePublisher stpub ON stp.SoftwareTitlePublisherID = stpub.SoftwareTitlePublisherID
LEFT JOIN SoftwaretitleVersion stv ON st.SoftwaretitleVersionID = stv.SoftwareTitleVersionID
LEFT JOIN SoftwareTitleEdition ste ON st.SoftwareTitleEditionID = ste.SoftwareTitleEditionID

The inventoryDate is per computer, not per application.

View solution in original post

(10) Replies

jjensen
By
Flexera Alumni

Hello @flexeranoob ,

Do you mean something like this?:

SELECT
cc.ComputerName AS 'Hostname',
cc.IPAddress,
st.FullName AS 'Application',
cc.InventoryDate
FROM InstalledApplications ia
JOIN ComplianceComputer cc ON cc.ComplianceComputerID = ia.ComplianceComputerID
JOIN SoftwareTitle st ON st.SoftwareTitleID = ia.SoftwareTitleID
WHERE cc.ComputerName = 'deviceName1'

HTH,

Joseph

If my response answered your question satisfactorily, please click "ACCEPT AS SOLUTION" to heighten visibility for future customers!

Hi @jjensen thanks, something like this, but for all devices.  Can you please help me and add that part. I am not so good at joins. and definitely not at optimizing queries. 

@flexeranoob,

In theory, you could just remove the WHERE clause if you wanted a return set for all devices.

However - this is potentially going to return a LOT of rows (1 per application per device), so I wouldn't recommend running such a query without considering performance first.
If my response answered your question satisfactorily, please click "ACCEPT AS SOLUTION" to heighten visibility for future customers!

mfranz
By Level 17 Champion
Level 17 Champion

Just leave out the WHERE line.

SELECT
cc.ComputerName AS 'Hostname',
cc.IPAddress,
st.FullName AS 'Application',
cc.InventoryDate
FROM InstalledApplications ia
JOIN ComplianceComputer cc ON cc.ComplianceComputerID = ia.ComplianceComputerID
JOIN SoftwareTitle st ON st.SoftwareTitleID = ia.SoftwareTitleID

 

Is there a way I can application version to it?

mfranz
By Level 17 Champion
Level 17 Champion

Application version should be part of the FullName attribute. If you want distinct fields for version, edition, etc. the query would include additional tables:

SELECT
cc.ComputerName AS 'Hostname',
cc.IPAddress,
stpub.PublisherName,
stp.ProductName,
stv.VersionName,
ste.EditionName,
cc.InventoryDate
FROM InstalledApplications ia
JOIN ComplianceComputer cc ON cc.ComplianceComputerID = ia.ComplianceComputerID
JOIN SoftwareTitle st ON st.SoftwareTitleID = ia.SoftwareTitleID
JOIN SoftwareTitleProduct stp ON st.SoftwareTitleProductID = stp.SoftwareTitleProductID
JOIN SoftwareTitlePublisher stpub ON stp.SoftwareTitlePublisherID = stpub.SoftwareTitlePublisherID
LEFT JOIN SoftwaretitleVersion stv ON st.SoftwaretitleVersionID = stv.SoftwareTitleVersionID
LEFT JOIN SoftwareTitleEdition ste ON st.SoftwareTitleEditionID = ste.SoftwareTitleEditionID

The inventoryDate is per computer, not per application.

Thank you guys!  This should work.  let me get back to you!!! You are super helpful!

Thanks again.  This query is heavy.  I guess I could limit it to Commercial software by linking it to SoftwareTitleClassification table?

mfranz
By Level 17 Champion
Level 17 Champion

Here you go.

SELECT
cc.ComputerName AS 'Hostname',
cc.IPAddress,
stpub.PublisherName,
stp.ProductName,
stv.VersionName,
ste.EditionName,
cc.InventoryDate
FROM InstalledApplications ia
JOIN ComplianceComputer cc ON cc.ComplianceComputerID = ia.ComplianceComputerID
JOIN SoftwareTitle st ON st.SoftwareTitleID = ia.SoftwareTitleID
	AND st.SoftwareTitleClassificationID = 3 -- Commercial
JOIN SoftwareTitleProduct stp ON st.SoftwareTitleProductID = stp.SoftwareTitleProductID
JOIN SoftwareTitlePublisher stpub ON stp.SoftwareTitlePublisherID = stpub.SoftwareTitlePublisherID
LEFT JOIN SoftwaretitleVersion stv ON st.SoftwaretitleVersionID = stv.SoftwareTitleVersionID
LEFT JOIN SoftwareTitleEdition ste ON st.SoftwareTitleEditionID = ste.SoftwareTitleEditionID

mfranz
By Level 17 Champion
Level 17 Champion

If you would like to start SQL scripting or have a little refresh, there is a free SQL course on www.sololearn.com.