Adding Scripts to SQL Server Project



This blog explains how to add SQL object scripts and post deployment scripts to previously created SQL Server project here


Adding SQL Scripts:

Right click on the folder structure that you want to create the script and choose appropriate script option to add,

Added 2 Tables and 1 Stored Procedure to the dbo schema,



Adding Post-Depolyment Script:

Often we need to add seed data to tables.

This can be achieved using post-deployment scripts.

Note: Make sure to have only one post-deployment script per project.

Below is the way to add post-deployment script,

Once the Post-Deployment script is added, you can add your seed data directly to this file, but this will not be clean.so the recommended option is add a file with your data and reference that file in Post-Deployment script as below,

:r .\Script.PostDeploymentEmployeeType.sql

:r .\Script.PostDeploymentDepartment.sql

Finally you successfully added your scripts to project and next post we will see how to create a schema compare file and publishing the changes to target database.