Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stored procedure sp_detach_db/sp_attach_db

Status
Not open for further replies.

marknav

Programmer
Sep 26, 2002
14
0
0
US
Hi,

I want to use a system stored procedure sp_detach_db and sp_attach_db.
I am not familiar with sp and need help to execute one.
These sp are not displayed under my DB
but i did find them in the master DB.
How do i run them?
Can i run them from the master DB but make it work on my db?
and what is the syntax to execute them if so?
Should i use the query analyzer to run them?
Thank you





 
These SPs are system stored procedures. They are only in the master database. You should not be in your database when you detach it. Execute tehe stored procedures from master. Once it is detached, you cannot be in it becasue it doesn't exist in SQL Server. You can execute SPs from Query Analyzer or any other tool that allows you to execute T-SQL.

Examples:

Exec sp_detach N'yourdatabase'

Exec sp_attach_db @dbname = N'yourdatabase',
@filename1 = N'F:\MSSQL\Data\yourdatabase.mdf',
@filename2 = N'G:\MSSQL\Data\yourdatabase_log.ldf' Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top