Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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. – dsjbirch 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. – dsjbirch Dec 11 '15 at 14:01
    
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. – l--''''''---------'''''''''''' Dec 11 '15 at 15:10
up vote 13 down vote accepted

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

share|improve this answer
2  
Additionally, sp_who2 will give you more information than sp_who. – joeqwerty Oct 29 '10 at 1:03
    
awesome! thanks for the tip. – natxo asenjo Oct 29 '10 at 6:05

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.

share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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