Showing posts with label max. Show all posts
Showing posts with label max. Show all posts

Wednesday, March 7, 2012

Closing all connections

How do I set up a job so that I close all open database connections? I think we have a leak in our code which causes our DB to go down (max connections used) roughly once every month, so we just restart the SQL server. Until we can find the exact problem I'd like to do this.

For simplicities sake let's say my database name is just "test."

Thank you.I've seen 2 ways to do this:

1) an ALTER DATABASE command, setting the database into single user mode and kicking out all connections

ALTER DATABASE Test
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE

followed by a

ALTER DATABASE Test
SET MULTI_USER

2) a stored procedure which loops through a cursor of all connections and KILLs them. For example code, look here:Kill all the Active Connections to Your Database.

Terri|||Thank you for your help. Sorry for the immensely delayed response. Things have been far beyond hectic lately.

As far as method 2, do you know how to check how many connections are active? I wanna know if killing it actually DID close the connections.|||I believe you can use sp_who to see this information, and sp_who2 to see more detail.

Terri|||Thank you very much tmorton.

Friday, February 10, 2012

Clearness needed in Sp_attach_db

Hi

With the sql server on line help , The syntax for the sp_attach_db has
the file name .It is aslo given that max of 16 files can be geven. I
attached a db with a single d.mdf .

could u pls tell what r the 16 file types or how a db can be attached
with 16 files.

With thanksYou can use CREATE DATABASE ... FOR ATTACH to attach a database of more
than 16 files. See the SQL 2000 Books Online
<tsqlref.chm::/ts_create_1up1.htm> for details.

BTW, sp_attach_db and sp_single_file_attach_db are basically just
wrappers for this command.

--
Hope this helps.

Dan Guzman
SQL Server MVP

--------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index...epartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
--------

"Raghuraman" <raghuraman_ace@.rediffmail.com> wrote in message
news:66c7bef8.0311160458.621723bc@.posting.google.c om...
> Hi
> With the sql server on line help , The syntax for the sp_attach_db has
> the file name .It is aslo given that max of 16 files can be geven. I
> attached a db with a single d.mdf .
> could u pls tell what r the 16 file types or how a db can be attached
> with 16 files.
>
> With thanks