List of currently active sessions for each database on your servers.
Please note that you need VIEW SERVER STATE permission to view all the sessions. Otherwise, you’ll see only your own.
--- Currently Active Sessions
Select
s.spid as 'pid'
,s.blocked as 'Blocks'
,RTRIM(CAST(s.hostname as nvarchar(256))) as 'FromServer'
,RTRIM(CAST(s.loginame as nvarchar(256))) as 'UserName'
,RTRIM(CAST(d.name as nvarchar(256))) as 'DatabaseName'
,RTRIM(REPLACE(s.lastwaittype,'RESERVED_MEMORY_ALLOCATION_EXT ','RES_MEM_ALLOC_EXT')) as 'WaitType'
,s.waittime / 1000 as 'WaitTime' -- wait time in seconds
,RTRIM(CAST(s.cmd as nvarchar(32))) as 'Statement'
,s.status as 'Status'
,c.num_reads as 'PageReads' -- number of packet reads
,c.num_writes as 'PageWrites' -- number of packet writes
,RTRIM(CAST(s.program_name as nvarchar(256))) as 'ProgramName'
,t.text as 'ExecutedQuery'
,datediff(minute,s.last_batch, GETDATE()) as 'Duration' -- execution time in munites
--,EQP.query_plan as 'execution plan'
-- r.percent_complete
--into #tmp
from sys.sysprocesses s
join sys.databases d on d.database_id = s.dbid
left join sys.dm_exec_requests r on r.session_id = s.spid
cross apply sys.dm_exec_sql_text (s.sql_handle) t
--CROSS APPLY sys.dm_exec_query_plan(r.plan_handle) AS EQP
inner join sys.dm_exec_connections c
on c.session_id = s.spid
where (s.cmd not like '%AWAITING%' or s.status = 'suspended')
and t.text not like '%--- Currently Active Sessions Select%'
order by duration desc
80 Responses
Great post. I was checking constantly this blog and I’m impressed!Very useful information specially the last part 🙂 I care for such information a lot.I was looking for this certain information for a very long time.Thank you and best of luck.
It’s an amazing paragraph designed for all the online visitors; they willobtain advantage from it I am sure.
Very neat article. Cool.
HAVE A FREE CONSULTATION NOW
Good day! This post could not be written any better!Reading this post reminds me of my good old room mate! Healways kept chatting about this. I will forward this write-up tohim. Fairly certain he will have a good read. Thanks for sharing!
Thanks again for the post.Thanks Again. Will read on…
This is one awesome blog article. Fantastic.
Great, thanks for sharing this article.Much thanks again. Keep writing.
Hi my loved one! I wish to say that this article is awesome, nice written and come with approximately all significant infos. I’d like to look extra posts like this.
about PlayStation 4, feel to sell them, of course we
Hey, thanks for the blog post.Really looking forward to read more. Really Great.
Wow, this is very interesting to read. Have you ever considered submitting articles to magazines?
orlistat does it work – orlistat manufacturer xenical ema
Hello there! I just wish to offer you a huge thumbs up for your excellent information you have right here on this post. I will be coming back to your blog for more soon.
Major thanks for the post.Thanks Again. Great.
Very good info. Lucky me I found your blog by chance (stumbleupon). I ave book-marked it for later!
Remarkable things here. I am very satisfied to peer your post. Thank you a lot and I’m looking forward to touch you. Will you kindly drop me a e-mail?
tamoxifen breast cancer tamoxifen and bone density – tamoxifen brand name
It’s an remarkable post designed for all theinternet visitors; they will obtain benefit from it Iam sure.
ivermectin 8000 ivermectin tablets for humans – stromectol pill
Usually I do not learn article on blogs, however I wish to say that this write-up very pressured me to take a look at and do it! Your writing taste has been surprised me. Thanks, very great article.
Thanks for another magnificent article. Where else could anybody get that kind of info in such a perfect way of writing? I have a presentation next week, and I’m on the look for such info.
I do trust all the concepts you have introduced in your post. They are really convincing and will certainly work. Nonetheless, the posts are too brief for newbies. Could you please extend them a bit from next time? Thank you for the post.
I really enjoy the article post.Really looking forward to read more. Really Cool.
Amazing! This blog looks exactly like my old one! It’s on a completely different subject but it has pretty much the same layout and design. Excellent choice of colors!
Very neat blog post.Really looking forward to read more. Cool.Loading…
I really liked your blog article.Thanks Again. Great.
I savour, result in I found exactly what I usedto be looking for. You have ended my four day lengthy hunt!God Bless you man. Have a great day. Bye
There is visibly a package to find out about this. I assume you made sure wonderful factors in features likewise. Hannie Tull Durant
A fascinating discussion is definitely worth comment.I do think that you should publish more about this subject, it mightnot be a taboo subject but generally folks don’t speak aboutthese issues. To the next! All the best!!
ed medications comparison: erectyle dysfunction best ed treatments
When I initially commented I clicked the “Notify me when new comments are added” checkbox andnow each time a comment is added I get several e-mails with the same comment.Is there any way you can remove people from that service?Thanks a lot!
Say, you got a nice article.Thanks Again. Really Cool.
Actually no matter if someone doesn’t know after that its up to other people thatthey will assist, so here it happens.
Thanks for the marvelous posting! I seriously enjoyed readingit, you will be a great author.I will be sure to bookmark your blog anddefinitely will come back down the road. I want to encourage you continue your great writing,have a nice weekend!
What a material of un-ambiguity and preserveness of preciousfamiliarity on the topic of unpredicted feelings.
Hi, I do think this is an excellent blog. I stumbledupon it 😉 I am going to revisit once again since i have saved as a favorite it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.
Thank you for your blog.Much thanks again.
I need to to thank you for this very good read!! I definitely enjoyed every bit of it. I’ve got you book marked to check out new things you postÖ
It’s hard to find knowledgeable people for this subject, however, you sound like you know what you’re talking about! Thanks
I am so grateful for your blog post.Thanks Again. Really Great.
Looking forward to reading more. Great blog article.Thanks Again. Really Cool.
What’s up mates, how is everything, and what you desire to say about this post, in my view its genuinely amazing for me.
Thanks for sharing your info. I really appreciate your efforts and I am waiting for your next write ups thanks once again.
ブランドバッグコピー2 Wire CablePaper Straw Making Process
Table 1 reports the benefits of this baseline counterfactual calculation.
Seriously a lot of wonderful advice.admission essay editing services cpm homework essay writing services reviews
amlodipine doses blood pressure tablets amlodipine
mens erection pills natural treatments for ed – ed pills otc
Thanks a lot for the blog post. Great.
vardenafil online canada – vardenafil online bestellen ordering vardenafil online
Good way of telling, and good piece of writing to obtain facts on the topic of my presentation focus, which i am going to convey in college.
I value the article. Great.
ramipril dosierungen amlodipine solubility amiodarone drip
A round of applause for your blog article.Thanks Again. Want more.
This is one awesome blog.Really thank you! Cool.
I really like looking through an article that can make people think. Also, many thanks for allowing me to comment!
I am actually pleased to read this blog postswhich contains plenty of useful facts, thanks for providing these kinds of statistics.My blog post; testosterone center
Propecia Adverse Effects Swelling Of The Lips
how long does azithromycin affect birth control – azithromycin cvs over the counter z pack dental infection
clonopine meaning hydroxychloroquine reviews
Enjoyed every bit of your article post.Really looking forward to read more. Keep writing.
Itís nearly impossible to find well-informed people on this subject, however, you sound like you know what youíre talking about! Thanks
Thanks for sharing, this is a fantastic post.Much thanks again. Much obliged.
Wonderful goods from you, man. I have understand your stuff previous to and you’re
I’d need to check with you here. Which isn’t one thing I normally do! I get pleasure from studying a publish that will make people think. Additionally, thanks for allowing me to comment!
ncov chloroquine chloroquine stock hydrochlorique
Hi, I do believe this is an excellent blog. I stumbledupon it 😉 I will come back yet again since I saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to help other people.
provigil online provigil online modafinil
Hi there, this weekend is nice designed for me, for the reason that this moment i am reading this fantastic informative piece of writing here atmy residence.Review my blog – stampedblueprint.com
Thanks for the update, is there any way I can receive an alert email every time there is a new article?
I needed to thank you for this very good read!! I absolutely enjoyed every little bit of it.I have got you book-marked to check out new stuff you post…
Hi there! Would you mind if I share your blog with my twitter group?There’s a lot of folks that I think would really enjoy your content.Please let me know. Thank youLook into my blog post: One Shot Max Keto Reviews (haojiafu.net)
Very good post.Much thanks again. Will read on…
Hi there, just became aware of your blog through Google, and found that it is truly informative.I’m gonna watch out for brussels. I’ll be grateful if you continue this in future.Lots of people will be benefited from your writing.Cheers!
Hi there! Do you know if they make any plugins to assist with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success. If you know of any please share. Cheers!
Hi, yes this post is truly good and I have learned lot of things from it about blogging. thanks.
Your style is so unique in comparison to other folks I’ve read stuff from.
I appreciate you sharing this blog article. Want more.
I couldn챠t refrain from commenting. Well written!