Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

what is the syntax for sp_detach

Posted on 2004-09-22
2
Medium Priority
?
2,003 Views
Last Modified: 2010-05-18
what is the code to detach a database and reattach a database?
0
Comment
Question by:CFDevHead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 300 total points
ID: 12125969
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
 
LVL 15

Assisted Solution

by:mcmonap
mcmonap earned 200 total points
ID: 12125989
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question