12

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?

SteveC
  • 271
  • 3
  • 8
  • 21
Alex Gordon
  • 455
  • 3
  • 14
  • 31
  • 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

4 Answers4

17

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

exec sp_who
go

it will probably work in 2008.

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

natxo asenjo
  • 5,739
  • 2
  • 26
  • 27
8

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.

Shane
  • 1,869
  • 4
  • 20
  • 34
1

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
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
-3

You can use a built in sql stored procedure.

exec sp_who go