Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do I need to stop the Database befor detach and attach database?

Status
Not open for further replies.

dk2006

MIS
Jan 19, 2006
53
US
I try to make two databases synchronize in both production and development servers. I am using detach and attach method. Do I need to stop database in SQL Server Service Manager first? I keep getting 'currently in use' error.

Thanks,
dk
 
The currently in use message occurs when someone else is connected to the database.

In QA, you can use sp_who and/or sp_who2 to see who is connected to the database.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
George,
This is a very fast response. Thanks. So I don't need to stop the service?

dk
 
Ordinarily, you don't want to just stop the service just to detach a database. You can, but you have to realize that it will stop ALL the databases attached to that server.

By using sp_who, you can see the process9es) that are connected to the database you want to detach by looking at the DBName column.

You can even stop the process by using the kill command. Do NOT kill any processes with a SPID < 50. Those are reserved for SQL Server.

Just find the SPID and enter into QA...
Kill 55
This will kill the process with a SPID of 55 (55 being an example).



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top