mah_j (10/22/2016)
HelloHow can I stop the long running query that is run from application?
I want to kill the queries that are running longer than 40 seconds.
I don't know if you're the "DBA" or just a person who's been put into a position of high trust but killing SPIDs of long running queries from an application is a total violation of the trust you've been given. Your job is to make data available at all times and killing long running queries is severely contrary to the requirements of that job. A query that runs too long means that query isn't making the data available in a reasonable time.
What you need to do is...
1. Identify what the queries are.
2. Identify what the parameters for the queries are.
3. Using the information from #1 and #2 above, figure out what the problem with the queries are.
4. Either fix the queries or make recommendations as to how the queries can be fixed.
Is it going to be painful to do so? Most likely but that's a part of your job.
If you're trying to make a point to management, then don't kill the queries. Let them run forever and document them and the problems they're causing to the system. Simply killing them is just going to mask the problem.
Stop putting Band-Aids on stab wounds and fix the real problem.
--Jeff Moden
Change is inevitable... Change for the better is not.