SQL Server Data Tools How to save data with a schema?

I am using a SQL Server project to manage the database structure.

First I created a project and then imported the database.

Then, when I need to change the schema, say, change the name of the field, I will do it in the SQL Server project and then publish it to the actual database using the schema comparison option.

I would like to take this step further to store the basic data needed for the database. Let's say, for example, a table OrderTypewith 2 entries "PHONE", "WEB"

This data will be needed in all new database instances. Is there a way to save them in a SQL Server project so that they are not lost?

It seems the only way to do it now is to save the actual copy of the main database with metadata in it, and then use data comparison. But it would be great if the data could simply be published at the same time as the schema so that the final database would be completed.

+4
source share
1 answer

There are two ways to save static data and publish it using a database.

  • You have a basic database with static data. When publishing a new instance, SQL Server Data tools have a Compare Data tool, which allows you to compare with live databases and creates a custom script to update one database with data from another.

  • , insert, . SQL Server Data .

    . ( SQL Server " " ), "Script" . script . MSDN

    . script "Post Deployment" script. script , Post Deployment script. MSDN

+3

Source: https://habr.com/ru/post/1615905/


All Articles