简体   繁体   中英

SQL Server database export to another computer

I use SQL Server Managment Studio, SQL Server Express. I gererate a script with schema and data from Task -> Generate Script . And I try to import this script in other computer with the same SQL Server but this giving me error :

Directory lookup for the file "C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\WHFM.mdf" failed with the operating system error 3 (The system cannot find the path specified.).

What should I have done to import /export entire database from one PC to another .

If you read through the first few lines of the script, you will see code that specifies the name and location of the files of the database. In your case look for 'C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\WHFM.mdf' in your script. Then look at the directory structure of the target machine. You will need to either:

1. create a directory 'C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\' and make sure the sql instance on the machine has RW access to that directory.

or much better,

2. Modify the script to put the file in a location that the target server wants to put files.

In regards to #2, you can have the target server give you a hint as to where to put files by right-clicking on "Databases" in Microsoft SQL Server Management Studio and create a script to create a database. The directory of the files in the create database script from the target-server should show you what to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM