Is there a way to find out the progress of DBCC SHRINKFILE
statement?
Here is how I was running it
dbcc shrinkfile('main_data', 250000)
I am running above statement on both SQL Server 2005 and 2008.
[UPDATE] Here is the query I ran to check the progress and the text that's being run.
select T.text, R.Status, R.Command, DatabaseName = db_name(R.database_id)
, R.cpu_time, R.total_elapsed_time, R.percent_complete
from sys.dm_exec_requests R
cross apply sys.dm_exec_sql_text(R.sql_handle) T
Have you checked percent_complete in sys.dm_exec_requests?
Aaron's answer is spot on, but I'd like to caution you against running data file shrink as it causes horrible performance problems. I used to own the shrink code, so I know what I'm talking about. Checkout this blog post I wrote yesterday that shows you what I mean and advises how to effect a shrink without actually doing a shrink: Why you should not shrink your data files
Hope this helps!
PS One more thing to check if it's taking a long time and the percent_complete is not increasing - look for blocking. Shrink will infinite-wait for locks it needs.
Query below will show you result like this: track dbcc shrink status
Adding my own version for anyone interested, this converts the millsecond time columns into more readable minutes and seconds.
Or you can just run exec sp_who3.