I was trying to rename a database and it said that it needed to be exclusively locked to perform this operation ...

How can I check who is connected to it?

  • 7
    You've asked eight SQL 2008 questions since yesterday. It's great you're an active member here on SF, but perhaps you should ask which training materials would best assist you in learning SQL 2008? – jscott Oct 28 '10 at 20:07
  • @jscott the question you suggest is open ended. That isn't a good fit for stack's format You can make a book suggestion if you have one. SteveC is free to ask as many questions as he needs. – bluekeys Dec 11 '15 at 13:57
  • @dsjbirch Thanks for the follow up, but a lot has changed with "good fit" on SF in the past 5+ years. – jscott Dec 11 '15 at 13:58
  • @jscott, ha! I didn't look at the date. Have a nice day. – bluekeys Dec 11 '15 at 14:01
  • 1
    Learning through reading reference material is a great way to learn for some people. I've struggled throughout my life with concentration issues and have put in many thousands of hours and have decided I'm stupid or lazy. – Alex Gordon Dec 11 '15 at 15:10

If I recall correctly in 2005 you can type this in a new query and then execute it:

exec sp_who

it will probably work in 2008.

Yes, it will: http://msdn.microsoft.com/en-us/library/ms174313.aspx

  • 3
    Additionally, sp_who2 will give you more information than sp_who. – joeqwerty Oct 29 '10 at 1:03

You can use the Activity Monitor in SQL Server Management Studio. Once it's open look at the Processes section to see what is running, the login, database being used, and other helpful information.


I think to check number of active connections and their Databases, please use:

SELECT DB_NAME(dbid) as DBName, COUNT(dbid) as 'Number Of Connections',
    loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame

You can use a built in sql stored procedure.

exec sp_who go

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.