Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2010
  • Last Modified:

what is the syntax for sp_detach

what is the code to detach a database and reattach a database?
0
CFDevHead
Asked:
CFDevHead
2 Solutions
 
jdlambert1Commented:
If the name of the database is "Test" and you're going to keep the LDF, and the mdf and ldf are in the "C:\MSSQL\Data" directory:

sp_detach_db Test

sp_attach_db 'Test', 'C:\MSSQL\Data\Test_data.mdf', 'C:\MSSQL\Data\Test_log.ldf'
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now