My current project will send queries to an sql server constantly and It may use 100% of the memory or CPU.
How can I check if the server is nearing full utilization in a stored procedure so that I can decide whether to execute the queries or not or save some settings in a table so that the following queries can know the workload is high and decide what to do
If not, how can I prevent SQL server to reach full utilization?
More information about the case: Right now I know our current test server can process 40-50 queries per second (one specific stored procedure). And now we'll decide how many queries are sent to the server every second. If we set the amount even 1 higher than the expected, in the long run, the queries will eventually fill the virtual memory and out client will have to restart their sql server instance periodically.
Expected Results (For bounty hunters):
@memory_usage float, @cpu_usage float; /* in percentage */
Any ideas are welcomed. Thanks.