martes, 21 de diciembre de 2021

How to export a MS SQL Server database to a SQL script (database to sql file) with Microsoft SQL Server

Generating .sql file of your database with data

SQL Server Management Studio provides the ability to generate scripts for creating databases, tables, stored procedures, functions, views and inserting data. For smaller amounts of data, this method can be used to send table structures and/or data to Scribe Support for testing purposes.

To proceed, Open SSMS and access the database engine with the default Windows authentication (or from the connection that you want to access):

SQL Server Management Studio SSMS Login

Connect to the server and explore the databases in the object explorer. In our case, we want to export the my_database database, that, as you can see, is available in the Databases directory:

SQL Server Management Studio Database Viewer 

Do right click on the database and select Tasks and then on Generate Scripts:

Generate Scripts SQL Server

This will open the Generate and Publish Scrips dialog. As first step, define which tables of the database you want to export, optionally you can script the entire database and objects:

Export Tables MS SQL Server Management Studio

After confirm which tables do you want to export, proceed to define if you want a single file per table or everything in a single file. If you go to the advanced scripting options, you can define the types of data to script, this means if you want to include the data on the file directly or only the structure of the database:

SQL Server Export Data and Structure

Finally, the export will begin and you will see the success message at the end:

Success SQL Server Script Structure and Data Export

 

 

https://ourcodeworld.com/articles/read/846/how-to-export-a-ms-sql-server-database-to-a-sql-script-database-to-sql-file-with-microsoft-sql-server-management-studio-17

No hay comentarios:

Publicar un comentario