Microsoft KB Archive/290623

= How to attach an existing SQL Server 2000 Database to SQL Server 2000 Desktop Engine =

Article ID: 290623

Article Last Modified on 4/6/2007

-

APPLIES TO


 * Microsoft Office Access 2007
 * Microsoft Office Access 2003
 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q290623



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

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

For a Microsoft Access 2000 version of this article, see 208888.



SUMMARY
You may have a need to copy an existing database from Microsoft SQL Server 2000 and to place the database on another computer that is running Microsoft SQL Server 2000 Desktop Engine. This article describes how to do so. 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 SQL Server 2000 Desktop Engine server there.

NOTE: The previous version of Microsoft SQL Server 2000 Desktop Engine is named Microsoft Data Engine (MSDE).



MORE INFORMATION
The following steps demonstrate how to copy the sample pubs database from a computer that is running SQL Server 2000 and how to place it on a computer that is running SQL Server 2000 Desktop Engine:  On the server that is running SQL Server 2000, open SQL Server Query Analyzer, and type the following line:

sp_detach_db pubs

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

NOTE: Temporarily detaching the database from the server allows you to copy the data and log files. In Windows Explorer, copy Pubs.mdf and Pubs_log.ldf from the Microsoft SQL Server\MSSQL\Data folder on the server to the Microsoft SQL Server\MSSQL\Data folder on the SQL Server 2000 Desktop Engine computer  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:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf', @filename2 = 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'  Use your copy of SQL Server 2000 Desktop Engine to open any working Access project. Click Queries, and then click New.</li> In the New Query dialog box, click Create Text Stored Procedure, and then click OK.</li>  Type the following statements in the new procedure.

NOTE: Some of the general stored procedure text may already be there. Also, your copy of SQL Server 2000 Desktop Engine may be on a drive other than drive C. <pre class="fixed_text">  Create Procedure AttachDB

As

EXEC sp_attach_db @dbname = 'pubs',

@filename1 = 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf', @filename2 = 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf'

return </li> Save the stored procedure, and then close it.</li> Double-click AttachDB to run it. Note that you receive a message that indicates that no records were returned. Click OK.</li></ol>

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

Additional query words: OfficeKBHowTo inf msde 2000 msde2000 ACC2002 ACC2003 ACC2007 reviewdocid

Keywords: kbclientserver kbhowto KB290623

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.