SET DATEFORMAT dmy
DECLARE @TODAY smalldatetime = GETDATE()
SELECT DISTINCT
SYS.Name0 AS [Computer Name],
CPU.Manufacturer0 AS [Manufacturer],
CPU.Name0 AS [Name],
CPU.NumberofLogicalProcessors0 AS [Logical CPU Count],
CPU.NumberofCores0 AS [Number of Cores per CPU],
CS.NumberofProcessors0 AS [Number of CPUs],
CASE
WHEN SYS.Is_Virtual_Machine0 = 1 THEN 'Virtual'
ELSE 'Physcial'
END AS [Server Type],
RAM.TotalPhysicalMemory0 / 1024 / 1024 AS [Memory (GB)],
SQL.InstanceName0 AS [Instance Name],
CASE
WHEN SQL.Version0 LIKE '8.%' THEN 'SQL 2000'
WHEN SQL.Version0 LIKE '9.%' THEN 'SQL 2005'
WHEN SQL.Version0 LIKE '10.%' THEN 'SQL 2008'
WHEN SQL.Version0 LIKE '10.%' THEN 'SQL 2008 R2'
WHEN SQL.Version0 LIKE '11.%' THEN 'SQL 2012'
WHEN SQL.Version0 LIKE '12.%' THEN 'SQL 2014'
WHEN SQL.Version0 LIKE '13.%' THEN 'SQL 2016'
ELSE 'UnKnown'
END AS [Version],
SQL.Edition0 AS [Edition],
SQL.InstanceType0 AS [Instance Type],
SQL.TCPPort0 AS [SQL TCPPort]
FROM v_R_System SYS
INNER JOIN v_GS_Processor CPU
ON SYS.ResourceID = CPU.ResourceID
INNER JOIN v_GS_COMPUTER_SYSTEM CS
ON SYS.ResourceID = CS.ResourceID
INNER JOIN v_gs_x86_pc_memory RAM
ON SYS.ResourceID = RAM.ResourceID
INNER JOIN v_GS_SQLINSTANCE SQL
ON SYS.ResourceID = SQL.ResourceID
INNER JOIN v_FullCollectionMembership FC
ON SYS.ResourceID = FC.ResourceID
INNER JOIN v_Collection VC
ON FC.CollectionID = VC.CollectionID
WHERE FC.CollectionID LIKE @ColID
AND SQL.InstanceType0 LIKE @SQLInstanceTypes
AND CASE
WHEN SQL.Version0 LIKE '8.%' THEN 'SQL 2000'
WHEN SQL.Version0 LIKE '9.%' THEN 'SQL 2005'
WHEN SQL.Version0 LIKE '10.%' THEN 'SQL 2008'
WHEN SQL.Version0 LIKE '10.%' THEN 'SQL 2008 R2'
WHEN SQL.Version0 LIKE '11.%' THEN 'SQL 2012'
WHEN SQL.Version0 LIKE '12.%' THEN 'SQL 2014'
WHEN SQL.Version0 LIKE '13.%' THEN 'SQL 2016'
ELSE 'UnKnown'
END LIKE @SQLVersions
Then I have a few secondary querries:
All_Collections:
SELECT DISTINCT
c.CollectionID,
c.Name
FROM v_collection c
WHERE c.CollectionType = 2
ORDER BY c.Name
SQL_Instance_Type:
SELECT DISTINCT
SQL.InstanceType0 AS [Instance Type]
FROM v_GS_SQLINSTANCE SQL
UNION SELECT ''
ORDER BY [Instance Type]
SQL_Version:
SELECT DISTINCT
CASE
WHEN SQL.Version0 LIKE '8.%' THEN 'SQL 2000'
WHEN SQL.Version0 LIKE '9.%' THEN 'SQL 2005'
WHEN SQL.Version0 LIKE '10.%' THEN 'SQL 2008'
WHEN SQL.Version0 LIKE '10.%' THEN 'SQL 2008 R2'
WHEN SQL.Version0 LIKE '11.%' THEN 'SQL 2012'
WHEN SQL.Version0 LIKE '12.%' THEN 'SQL 2014'
WHEN SQL.Version0 LIKE '13.%' THEN 'SQL 2016'
ELSE 'UnKnown'
END AS [Version]
FROM v_GS_SQLINSTANCE SQL
UNION SELECT ''
ORDER BY [Version]
Then of Course I have 3 parameters @ColID, @SQLInstanceTypes, @SQLVersions
I do not know how to allow for multiple selections on the parameters for example I may want to choose multiple collections or SQL Version and so... I now within the parameter you can set to allow multiple but then I just get an error when choosing multiple. What is the proper way to allow multiple choices how do I need to update the parameter and the queries?
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
I have my main SQL Query:
Then I have a few secondary querries:
All_Collections:
SQL_Instance_Type:
SQL_Version:
Then of Course I have 3 parameters @ColID, @SQLInstanceTypes, @SQLVersions
I do not know how to allow for multiple selections on the parameters for example I may want to choose multiple collections or SQL Version and so... I now within the parameter you can set to allow multiple but then I just get an error when choosing multiple. What is the proper way to allow multiple choices how do I need to update the parameter and the queries?
Share this post
Link to post
Share on other sites