Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Can you find out how many connections?

Author  Topic 

silas2
Yak Posting Veteran

65 Posts

Posted - 2005-08-17 : 13:57:06
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

38200 Posts

Posted - 2005-08-17 : 14:01:57
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
Go to Top of Page

silas2
Yak Posting Veteran

65 Posts

Posted - 2005-08-17 : 14:28:55
Just disconnect them, seems a bit harsh...
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-08-17 : 14:30:48
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 - 2005-08-17 : 14:47:35
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
   

- Advertisement -