How to simulate a long-running query in SQL Server

Viewed 2355

I am trying to simulate a long-running query in mssql to test out some kill commands and clean-up operations. The problem is, I cannot figure out a way to keep a query running for a long-time. Here is what I'm currently doing:

select * from sales1 cross join sales2 cross join sales3 ...

The query returns immediately though if I do cursor.fetchall() it takes forever to fetch the results.

While that's returning, when I do:

cursor.execute("sp_who2 'active'")

It doesn't show that query (I suppose because it's already 'executed').

Is there a way to emulate a long-running query with only one table of 100 results?

2 Answers

In my company we get alerts on OPEN TRANSACTION/LONG QUERY by users (or even DBA's)

So yes, OPEN TRAN without COMMIT/ROLLBACK will do it, or use WAITFOR DELAY

Related