SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Can you find out how many connections?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

silas2
Yak Posting Veteran

United Kingdom
65 Posts

Posted - 08/17/2005 :  13:57:06  Show Profile  Reply with Quote
Is there a way you can find out how many conneections to a database there may be before running (for example) a restore procedure to warn that it wil fail?

tkizer
Almighty SQL Goddess

USA
36601 Posts

Posted - 08/17/2005 :  14:01:57  Show Profile  Visit tkizer's Homepage  Reply with Quote
Why bother when you can easily disconnect them with this:
ALTER DATABASE DBNameGoes SET READ_ONLY WITH ROLLBACK IMMEDIATE
GO

RESTORE...
GO

And yes to see connections, you can run sp_who or sp_who2.

Tara

Edited by - tkizer on 08/17/2005 14:03:39
Go to Top of Page

silas2
Yak Posting Veteran

United Kingdom
65 Posts

Posted - 08/17/2005 :  14:28:55  Show Profile  Reply with Quote
Just disconnect them, seems a bit harsh...
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
36601 Posts

Posted - 08/17/2005 :  14:30:48  Show Profile  Visit tkizer's Homepage  Reply with Quote
But isn't that what you intend to do when you perform a restore? Why let it fail when their is a solution?

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 08/17/2005 :  14:47:35  Show Profile  Reply with Quote
sp_who2



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000