How to port SQL Server

Source: Internet
Author: User

After the application software development supported by SQL Server is completed on the local machine, the software should be deployed on the customer's computer, or the database should be transplanted to the server, and the application software should be operated on the client, at this time, we usually need to re-port the database. There are many methods to port the database. there are the following methods to summarize.

Prerequisites: Install SQL server before installing your application.

Method 1:

Backup/recovery

Back up the database first:

Backup database to disk = 'C:/backup. Bak'

Pack the backup file into the installer.

Recover the database when running the program for the first time (or create a system configuration program to control the completion of this task)

Restore database from disk = 'C:/backup. Bak'

Method 2:

Detach/Attach

Separate the database first:

Sp_detach_db 'database name'

Package the data file (. MDF) and log file (. LDF) into the installer.

Attach the database when running the program for the first time (or create a system configuration program to control and complete the work)

Sp_attach_db 'database name', 'Data file name (. MDF) ', 'Log file name (. LDF )'

Method 3

Use Database scripts

Generate database script:

Sql200 Enterprise Manager

-- Right-click the database to export

-- All tasks

-- Generate an SQL script

-- <General> select "generate all object scripts" and "include descriptive titles in script files ".

-- <Set format>, select "include extended attributes"

-- <Option>, select all content in "Table script option"

-- <Option>, "security option" determines whether to include the settings for creating databases and user permissions. Select

-- Keep default values for all other options

-- Then confirm and save it as a. SQL file.

 

Package the script file into the installer.

When the program is run for the first time, execute the script (or a specific system configuration program) to control the completion of the job, and use the isql.exe file to complete the job.

Exec master.. xp_mongoshell 'isql/e/I ". SQL file "'

You can also directly use the isql.exefile in the program or directly integrate the isql.exe file into the program installation package.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.