How to check SQL Query Status

Hi,
can someone please help with a problem i've just encountered. I have a classic asp page which runs a query and then creates an excel file using outlook web components. The problem is the query is still running when the open file dialog box appears so the file created is incomplete. Does anybody know how to check the status of the sql query or how to issue a wait command?

thanks in advance
cmsRuncornAsked:
Who is Participating?
 
Christian de BellefeuilleConnect With a Mentor ProgrammerCommented:
Sorry....  pick this one instead.

SELECT @@SPID AS 'ID', SYSTEM_USER AS LoginName, USER AS 'User Name'
WHERE SYSTEM_USER = 'YOUR LOGIN NAME HERE'
0
 
Christian de BellefeuilleProgrammerCommented:
Check this link

(if you are using an MSSQL server)
0
 
cmsRuncornAuthor Commented:
That's very helpful, thanks. But 1 question, how do i find out the current spid of the query so that i may check if the query is still running?
0
 
Christian de BellefeuilleProgrammerCommented:
You can find it this way...  

SELECT @@SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name'
WHERE [Login Name] = 'YOUR LOGIN NAME HERE'

0
All Courses

From novice to tech pro — start learning today.