Microsoft Knowledge Base Email Alertz

(208888) - 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...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 208888 - Last Review: June 28, 2004 - Revision: 2.0

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

This article was previously published under Q208888
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:
    sp_detach_db pubs
  2. 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.
  3. 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.
  4. 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):
        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.

  5. Click Stored Procedures, and then click New.
  6. 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.
       Create Procedure AttachDB
    
       As
    
       EXEC sp_attach_db @dbname = 'pubs',
    
           @filename1 = 'c:\mssql7\data\pubs.mdf',
           @filename2 = 'c:\mssql7\data\pubs_log.ldf'
    
       return
    					
  7. Save the stored procedure, and then close it.
  8. 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.

APPLIES TO
  • Microsoft Access 2000 Standard Edition
Keywords: 
kbhowto KB208888
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate