How to run the same query multiple times in SQL Server?
Simple example, I have a query
select * from sys.databases
I wanted to run it N times, because I wanted to return the data in a dashboard in "real time", until I stopped the execution, the select would need to continue running "example: as SQL Server Profiler does, while I don't stop, it keeps bringing the information in the screen".
What would be the best way for this type of situation?
Remembering that the query and SQL Server profiler are just examples.
CodePudding user response:
Because your dashboard code must poll the dbms every so often to get the latest data, you must decide how often as part of your system design.
Once a minute? That is very often to poll the data. But only you can decide how out-of-date your dashboard users will tolerate.
Whatever you do, avoid promising "real time" if you possibly can. We programmers can't deliver on that promise with polling the database.
CodePudding user response:
create a job and insert your query to run, and under the schedule set the timings to execute your query.