Please help to attach a database on sqlserver7 problem

Category: MS-SQL Server -> Foundation Classes Author: merit_lyy Date: 2009-05-12 19:27:36
 
merit_lyy
2009-05-12 19:27:36
In sqlserver7 from a database replication MDF. LDF database to another machine SQLSERVER7 how to MDF, LDF, database into this station machine SQLSERVER7, please give specific implementation steps
Thank
a24224138
2009-05-12 19:44:14
sp_attach_db
will attach the database to the server.

syntax
sp_attach_db [@ dbname =] 'dbname'
, [@ filename1 ; =] 'filename_n' [, ... 16]

parameter
[@ dbname =] 'dbname'

be attached to the name of the database server. The name must be unique. dbname is sysname, with a default of NULL.

[@ filename1 =] 'filename_n'

physical database file name, including the path. filename_n data type nvarchar (260), the default value is NULL. Can specify up to 16 file names. The parameter name is @ filename1 start, increment to @ filename16. File name list must include at least the master file, the master file contains links to other files in the database system tables. The list must also include all of the database after the separation of the file to be moved.

Return Code Values ​​
0 (success) or 1 (failure)

result set
No comments
should only be used before an explicit sp_detach_db operation a separate database from the database server execution sp_attach_db. If you must specify more than 16 files, use the FOR ATTACH clause with the CREATE DATABASE.

If you attach the database to the server is not isolated from the database server, and separate databases enabled for replication, you should run sp_removedbreplication deleted from the database replication.

Permissions
only sysadmin and dbcreator fixed server role can execute this procedure. Examples

pubs in the following example attaches two files to the current server.

EXEC sp_attach_db @ dbname = N'pubs',
@ filename1 = N'c: \ Program Files \ Microsoft SQL Server \ MSSQL \ Data \ pubs.mdf ',
@ filename2 = N'c: \ Program Files \ Microsoft SQL Server \ MSSQL \ Data \ pubs_log.ldf '

see

CREATE DATABASE

sp_attach_single_file_db

sp_detach_db

sp_helpfile

sp_removedbreplication

system stored procedure

© 1988-2001 Microsoft Corporation. All rights reserved.
eaglexu0403
2009-05-12 19:58:03
first detach, then copy, then attach
cliffcrag
2009-05-12 20:16:49
that database from the primary database to perform sp_detach_db executed after SP-ATTACK-DB command you