-- Drop stored procedure if it already exists
IF EXISTS (
SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE SPECIFIC_SCHEMA = N'dbo'
AND SPECIFIC_NAME = N'ServiceManager_Report_ConfigurationManagement_SP_ComputerInventoryGetData'
)
DROP PROCEDURE dbo.ServiceManager_Report_ConfigurationManagement_SP_ComputerInventoryGetData
GO
OS.OSVersionDisplayName,
OS.BuildNumber AS OSVersion
FROM
dbo.ComputerDimvw C
INNER JOIN @tableDomainDNSName tempDNS ON
('!<All>!' = tempDNS.value OR C.DomainDnsName = tempDNS.value)
LEFT OUTER JOIN
dbo.ComputerHostsOperatingSystemFactvw CHOSFact
ON C.ComputerDimKey = CHOSFact.ComputerDimKey
AND CHOSFact.DeletedDate IS NULL
LEFT OUTER JOIN
dbo.OperatingSystemDimvw OS
ON CHOSFact.ComputerHostsOperatingSystem_OperatingSystemDimKey = OS.OperatingSystemDimKey
INNER JOIN @tableOSVersionName tempOSVerName ON
('!<All>!' = tempOSVerName.value OR OS.OSVersionDisplayName = tempOSVerName.value)
INNER JOIN @tableOSVersion tempOSVer ON
('!<All>!' = tempOSVer.value OR OS.BuildNumber = tempOSVer.value)
LEFT OUTER JOIN
dbo.DeployedComputerRunsWindowsComputerFactvw WCOPCFact
ON C.ComputerDimKey = WCOPCFact.DeployedComputerRunsWindowsComputer_ComputerDimKey
and CHOSFact.DateKey = WCOPCFact.DateKey
and WCOPCFact.DeletedDate IS NULL
LEFT OUTER JOIN
dbo.DeployedComputerDimvw PC
ON WCOPCFact.DeployedComputerDimKey = PC.DeployedComputerDimKey
INNER JOIN @tableManufacturer tempMfc ON
('!<All>!' = tempMfc.value OR PC.Manufacturer = tempMfc.value)
INNER JOIN @tableModel tempMod ON
('!<All>!' = tempMod.value OR PC.Model = tempMod.value)
WHERE
((@NetBIOSComputerName IS NULL) OR (NetbiosComputerName LIKE @NetBIOSComputerName) ) AND
((@DNSName IS NULL) OR (DNSName LIKE @DNSName)) AND
(
(@IsVirtual IS NULL) OR
(ISNULL(C.IsVirtualMachine, 0) = @IsVirtual)
)
ORDER BY C.NetbiosComputerName
SET @Error = @@ERROR
QuitError:
RETURN @Error
END
GO
GRANT EXECUTE ON dbo.ServiceManager_Report_ConfigurationManagement_SP_ComputerInventoryGetData TO reportuser
GO