ACC2000: How to Attach Existing SQL Server 7.0 Database Files to Microsoft Data Engine (MSDE)

ID: Q208888


The information in this article applies to:
  • Microsoft Access 2000

Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access project (.adp).


SUMMARY

You may have a need to copy an existing database from Microsoft SQL Server 7.0 and to place the database on another computer that is running Microsoft Data Engine (MSDE). This article describes how to do so. To summarize, the process involves temporarily detaching the database from its server, copying the data file (.mdf) and log file (.ldf) to the target computer, and then attaching the files to the MSDE server there.


MORE INFORMATION

The following steps demonstrate how to copy the sample pubs database from a computer running SQL Server 7.0 and how to place it on a computer running MSDE:

  1. On the server running SQL Server 7.0, open SQL Server Query Analyzer, and type the following line:


  2. sp_detach_db pubs
  3. On the Query menu, click Execute (or press F5) to run the query. Not that you receive a message indicating that no records were returned.

    NOTE: Temporarily detaching the database from the server allows you to copy the data and log files.


  4. In Windows Explorer, copy Pubs.mdf and Pubs_log.ldf from the mssql7\data folder on the server to the mssql7\data folder on the MSDE computer.


  5. To attach the files to the SQL Server computer again, run the following statements in the Query Analyzer (your server's copy of SQL Server may be in a different location than this example; modify the path as needed):


  6. 
        EXEC sp_attach_db @dbname = 'pubs',
            @filename1 = 'c:\mssql7\data\pubs.mdf',
            @filename2 = 'c:\mssql7\data\pubs_log.ldf' 
    Use your copy of MSDE to open any working Access project.

  7. Click Stored Procedures, and then click New.


  8. Type the following statements in the new procedure.

    NOTE: Some of the general stored procedure text may already be there. Also, your copy of MSDE may be on a drive other than drive C.


  9. 
       Create Procedure AttachDB
    
       As
    
       EXEC sp_attach_db @dbname = 'pubs',
    
           @filename1 = 'c:\mssql7\data\pubs.mdf',
           @filename2 = 'c:\mssql7\data\pubs_log.ldf'
    
       return 
  10. Save the stored procedure, and then close it.


  11. Double-click AttachDB to run it. Note that you receive a message indicating that no records were returned. Click OK.


At this point, the pubs sample database is attached to your installation of MSDE, and you can create new Access projects from it.

Additional query words: inf

Keywords : kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 3, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.