Mr. Mihashi: How to import SQL Server database into sql file

Summary: WeChat search [ Sanqiao Jun ]

Articles are first published on the official account platform: https://mp.weixin.qq.com/s/bgcCwAf0K4xliyLEb5QGmg

Foreword:

In the process of learning the course of database, Mr. Mihashi was troubled many times by the problem of database import and export. There are many ways to import and export databases in SQL Server software, but many of them are more complicated and troublesome, and it is not convenient to find a solution even if an error is reported. This makes Sanqiao Jun usually prefer to directly compile the code to implement the project instead of tossing in and out.

Today, Mr. Mihashi studied the method of exporting the database and found that this method is so easy to use and convenient! So Mr. Mihashi let more people know this method.

 

One, the problem

When we want to export the SQL Server database to a file in sql format, we can open it with software on other computers. So, how to export it?

To this end, Mr. Mihashi spent a lot of time writing this tutorial.

 

Two, the solution

 

(1) Use the script generation function to export the database sql file

 

(1) Select the generation script of the database to be exported

 

(2) Click Next

 

(3) Click "Select specific database object". Then the next step.

If you want to export all of them, tick in front of the table, and partly tick in front of the specific table.

 

(3) Open advanced mode

This advanced mode is very important . If you want to export all the contents of the database, select "Schema and Data" after the "Type of data to be scripted". The default is the schema. If it is not set, the exported sql file has no data.

 

(4) "File name" Here you can set the save location and saved file name. Then the next step.

It is best to set it here, otherwise the exported file is not easy to find.

 

(5) Click Next

 

(6) Click to finish

Export the database as a sql file here to complete.

 

(Two) how to open sql file

First, open the sql file directly.

 

(1) If there is no database name of the original SQL file in the database

Then, create a new database with the same name, and then select all sql codes to execute.

 

(2) If there is the database name of the original SQL file in the database, it should be divided into situations:

1) If there is no data in the database, proceed directly as described above.

2) If there is data in the database, create a new database with a custom name, then change the database name after USE to the corresponding one, and then select all the sql codes to execute.

 


It is not easy to organize articles. If you have any help, please like and follow and support, thank you! Wechat search for [Mr. Sanqiao ] and reply [Follow] with a resource package prepared by me. Continued updates~~~

 

Guess you like

Origin blog.csdn.net/weixin_46218781/article/details/107346937