From 389439111bd972132b0efd79723931201440fa7a Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Thu, 18 May 2017 17:51:16 -0700 Subject: [PATCH] Fixed sqlserver input to work with case sensitive server collation. (#2749) Fixed a problem with sqlserver input where database properties are not returned by Telegraf when SQL Server has been set up with a case sensitive server-level collation. * Added bugfix entry to CHANGELOG.md for sqlserver collation input fix. (cherry picked from commit e2983383e4657ede489337fc1a38cf393020feee) --- CHANGELOG.md | 6 ++++++ plugins/inputs/sqlserver/sqlserver.go | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a021a724f..32b4ef15c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v1.3.1 [unreleased] + +### Bugfixes + +- [#2749](https://github.com/influxdata/telegraf/pull/2749): Fixed sqlserver input to work with case sensitive server collation. + ## v1.3 [2017-05-15] ### Release Notes diff --git a/plugins/inputs/sqlserver/sqlserver.go b/plugins/inputs/sqlserver/sqlserver.go index 1e7f92dff..ed3216258 100644 --- a/plugins/inputs/sqlserver/sqlserver.go +++ b/plugins/inputs/sqlserver/sqlserver.go @@ -843,7 +843,7 @@ FROM (SELECT DISTINCT DatabaseName FROM #Databases) AS bl SET @DynamicPivotQuery = N' SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -856,7 +856,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -869,7 +869,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -883,7 +883,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -896,7 +896,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -909,7 +909,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -922,7 +922,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -935,7 +935,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -948,7 +948,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -961,7 +961,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement)