Hi all,
as I have already mentioned in #34
some people will get a subsequent error when they use the conversion of the Performance Counter Output to varchar (20) inside the stored procedure spGetPerfCountersFromPowershell.
If you have a system which uses a comma instead of a point to mark your decimal place, then you will (of course) save your perf Counter values inside the table dba_local.dbo.CounterValue also with commas instead of points.
This leads to "Error converting data type varchar to float".
I have picked up the query the dashboard report uses:
exec sp_executesql N'DECLARE @CPUCOUNT int
SELECT @CPUCOUNT=cpu_count from sys.dm_os_sys_info
SELECT
Date,
ROUND([processor(_total)% processor time],0) as ''Processor Utilization'',
ROUND(([processor(_total)% privileged time][processor(_total)% processor time])/100,0) as ''Priviledged Utilization'',
ROUND(([processor(_total)% processor time][process(sqlservr)% processor time])/100/@CPUCOUNT,0) as ''SQL Utilization'',
ROUND([sql statistics\batch requests/sec],0) as ''Batch Request per second'',
ROUND([sql statistics\sql compilations/sec],1) as ''SQL Compilations per second'',
ROUND([sql statistics\sql re-compilations/sec],1) as ''SQL Recompilations per second'',
ROUND([General Statistics\User Connections],0) as ''User Connections'',
ROUND([logicaldisk(_total)\avg. disk sec/read]*1000.0,1) AS ''Disk Read Latency'',
ROUND([logicaldisk(_total)\avg. disk sec/write]*1000.0,1) AS ''Disk Write Latency'',
ROUND([memory\available mbytes],0) AS ''Available Memory In MB'',
ROUND([transactions\free space in tempdb (kb)]/1024.0/1024.0,0) AS ''Free Space in Tempdb''
FROM
(
select
CounterName,
CONVERT(varchar(20),DateSampled,101) as ''Date'',
ROUND(CounterValue,7) as ''CounterValue''
from PerformanceCounter
where CounterName IN (''processor(_total)% processor time'',''processor(_total)% privileged time'',''process(sqlservr)% processor time'',''sql statistics\batch requests/sec'',''sql statistics\sql compilations/sec'',''sql statistics\sql re-compilations/sec'',''General Statistics\User Connections'',''logicaldisk(_total)\avg. disk sec/read'', ''logicaldisk(_total)\avg. disk sec/write'', ''memory\available mbytes'',''transactions\free space in tempdb (kb)'')
and DateSampled between @StartDate and @EndDate
) AS p
PIVOT
(
AVG(CounterValue)
FOR
CounterName IN ([processor(_total)% processor time],[processor(_total)% privileged time],[process(sqlservr)% processor time],[sql statistics\batch requests/sec],[sql statistics\sql compilations/sec],[sql statistics\sql re-compilations/sec],[General Statistics\User Connections],[logicaldisk(_total)\avg. disk sec/read], [logicaldisk(_total)\avg. disk sec/write], [memory\available mbytes],[transactions\free space in tempdb (kb)])
) AS pivottable
Order by [Date]',N'@StartDate datetime,@EndDate datetime',@StartDate='2016-11-10 00:00:00',@EndDate='2017-05-10 10:00:00'
I made an adjustment to the EndDate to get data at all because I have set up a "fresh Monitoring".
When running the query I get the error., which is caused by the ROUND() in the sub-select.
So, a point to be discussed: do you want to fix every Report / query to work around the conversion error or does it make sense to load the data in a suitable format?
Regards
Dirk