Sami Karaeen


hi

is there way by code to stop the sql server service and deattach a database and then restard the service

thanks




Re: deAttach database

Caddre


You can detach a database with code but SQL Server service must be running because if it is not running, you cannot access anything in SQL Server. Try the link below for details about attach and detach database in SQL Server. Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms187858.aspx







Re: deAttach database

Sami Karaeen

thanks , but do u know how can i stop the sql server service




Re: deAttach database

Caddre

Yep here is some sample code from Microsoft to get you started. Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms162139.aspx






Re: deAttach database

Sami Karaeen

thanx a lot