MS SQL - Export database as SQL scripts

By xngo on September 3, 2019

In MS SQL server, you can export all data from tables to insertable SQL format. This feature is hidden. You have to do the followings.

  1. Right-click on your database name and select Tasks > Generate Scripts....
    MS SQL - Generate scripts
  2. Select tables that you want to export.
    MS SQL - Select tables
  3. On Set Scripting Options step, click on the Advanced button.
    MS SQL - Advanced button
  4. Scroll down to find Types of data to script line and change the value from Schema only to Data only or Schema and data.
    MS SQL - Types of data to script
  5. Continue to follow the instructions.
  6. MS SQL server will generate runnable SQL scripts with all the data.

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.