SQLSERVER- only the first sproc is executing in grafana

I have a variables/drop down of servers and serverports. I want to call a sproc per each combination of servers and serverports. This works in SQL server but not in Grafana. It only calls the first sproc.

  @StartDate datetime,
  @EndDate datetime,
  @i int, @j int, @ServerId smallint, @ServerName VARCHAR(100), @ServerPort VARCHAR(100)
  @StartDate =  DATEADD(HH,-1,  GETDATE()) 
  @EndDate = GETDATE()
  @ServerName ='[[ServerName:csv]]'

  @ServerPort =		'[[ServerPort]]'

select @i = 1 
while @i < len(REPLACE(@ServerName,',','')) + 1
    set @j = 1 
    while @j < len(REPLACE(@ServerPort,',','')) + 1
		declare @ServerIDFromQuery smallint = ( select ServerID from Server where ServerName = (select * from dbo.fnSplit(@ServerName, ',' ,@i)) and ServerPort = CAST((select * from fnSplit(@ServerPort , ',' ,@j)) as int))
      execute  DiagnosticLogGetGrafana  @StartDate ,  @EndDate, @ServerIDFromQuery, 18
		set @j = @j + 1
    set @i = @i + 1

How would I go about calling a sproc per each combination of servers+ports selected?


I can’t figure out a way I can call a SQL stored procedure per variables/drop down selected.

You cannot use a while loop. Please repeat variable per panel and call sproc in each panel.

but what if I want it all in one panel? I did it InfluxDB where I had variables as different tags and I did GROUP BY different TAGSin the Netrics query section. Trying to do the same in mssql

I did base my answer on that you had a sproc only taking a parameter holding a server id. You can A) change your sproc to support a list of values or B) skip the sproc and write the query directly in query editor field using WHERE … column IN($variable).