We have SQL server setup on one of our machines that is partitioned out. We
have the OS on drive C: and drive E: setup to house data. The problem is we
forgot that SQL server by default houses the actual data files on the C
drive in the SQL server directory. Our databases are already setup. What is
the best way to move those physical data files OFF the C drive and onto the
E drive. I tried through Enterprise Manager, but wasn't quite sure how. I
also tried stopping the services and making a copy of the files onto the E
drive and then creating a new database pointing to those copied files, but
that didn't work either. What's the best way to go about this. Bottom line,
we don't want the data files on the same partition as the OS. THANKS.You can do it with the help of sp_detach_db and sp_attach_db.
first use the sp_detach_db command to detach the database.
Eg
sp_detach_db 'pubs'
copy data and tran. log files to the destination drive.
after copying the files, you can use the sp_attach_db stored procedure to reattach the files to SQL
Server with the new location
See more help on this in BOL.
--
- Vishal|||Hi
Best way to do it is right click on the database you wnt
to move and say "detach" (you won't be able to detach
system databases but you can probably just leave them on
your C drive) . Then move the data and log files to the
drive where you want them. Then right click on Databases
in Enterprise manager and go to "all tasks", "Attach
database". Browse for the *.mdf in yournew location..the
rest is self explanatory.
Enjoy
-Jono|||The detach/attach thing worked perfectly. THANKS.
"Jono" <false@.me.co.nz> wrote in message
news:26d7301c38ebd$69c8db40$a601280a@.phx.gbl...
> Hi
> Best way to do it is right click on the database you wnt
> to move and say "detach" (you won't be able to detach
> system databases but you can probably just leave them on
> your C drive) . Then move the data and log files to the
> drive where you want them. Then right click on Databases
> in Enterprise manager and go to "all tasks", "Attach
> database". Browse for the *.mdf in yournew location..the
> rest is self explanatory.
> Enjoy
> -Jono|||In addition to the other posts, if you need to move files for the system databases, read article
224071.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Erich" <erich93063@.hotmail.com> wrote in message news:uQeaJrrjDHA.392@.TK2MSFTNGP11.phx.gbl...
> We have SQL server setup on one of our machines that is partitioned out. We
> have the OS on drive C: and drive E: setup to house data. The problem is we
> forgot that SQL server by default houses the actual data files on the C
> drive in the SQL server directory. Our databases are already setup. What is
> the best way to move those physical data files OFF the C drive and onto the
> E drive. I tried through Enterprise Manager, but wasn't quite sure how. I
> also tried stopping the services and making a copy of the files onto the E
> drive and then creating a new database pointing to those copied files, but
> that didn't work either. What's the best way to go about this. Bottom line,
> we don't want the data files on the same partition as the OS. THANKS.
>
No comments:
Post a Comment