Solved

what is the syntax for sp_detach

Posted on 2004-09-22
2
1,990 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 75 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 50 total points
ID: 12125989
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
[Unsupported] SQL Update in CRM 2011 Database 19 59
SSIS Column mapping 5 39
Remove () 9 35
Moving away from Access 2003 adp files 4 43
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

738 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