using SMO to detach a database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

so I notice to detach a database you use

Server svr = new Server();
svr.DetachDatabase("MyDatabase");

but is there a way you can set where its saved after detaching ? thansk
 
Detaching a database doesn't save anything about it. It simply removes
the database from the server. You will have to get the properties of the
files that make up the database before you detach it.
 
Detach is not actually removing anything like database. Files are staying in
the same folder where they were created. Just server forgets about these
files and ignores them on subsequent runs. That's why Nicholas mentions you
need to find out where files are residing before detaching. See ,mdf and ldf
files in BOL. Usually they are in Data subfolder of installation path.

HTH
Alex

Nicholas Paldino said:
Detaching a database doesn't save anything about it. It simply removes
the database from the server. You will have to get the properties of the
files that make up the database before you detach it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Rogelio said:
so I notice to detach a database you use

Server svr = new Server();
svr.DetachDatabase("MyDatabase");

but is there a way you can set where its saved after detaching ? thansk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top