Export (0) Print
Expand All

Managing SQL Server Express databases

If you need to copy, move, or delete a SQL Server Express database, you must first detach the database from the server. Do not detach a database currently in use.

To determine whether a database is in use, do any of the following:

  • Verify that the date included in the file name has passed.
  • Check whether a database with a higher number exists for the current date.
  • Enter the following lines at the command prompt, to list as SQL Server Express databases that currently have open connections:
    OSQL -S computer_name\MSFW -E
    sp_who2
    go
    

Detach a database by typing the following at a command prompt:

OSQL -S computer_name\MSFW -E
sp_detach_db database_name
go
quit

Where database_name is the name of the .mdf and .ldf files, without their extensions.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft