Publish data using SSDT?

I have an SSDT project. When publishing a new version, I want to publish and initialize some data in the database. Can this be done using SSDT?

+5
source share
4 answers

This can be done, but it can be difficult. If you set up a variable in the project that can be used for "new" releases, you can put this in your post-deployment script as a section that will launch a series of inserts, but only for this type of "New".

As David mentioned, the best way would probably be to use something like the Red-Gate data type to compare or run scripts after creating the database. This can be done in post-deployment scenarios, but can be difficult.

- :

IF '$(DeployType)' = 'New'
BEGIN --"New" release scripts
PRINT 'Post-Deploy Scripts for release.'
:r .\InsertScript1.sql
:r .\InsertScript2.sql
--etc
END --"New" release scripts
+3

SSDT. - script.

Redgate ReadyRoll , SSDT, , .

+2

Merge- , .

+1

, , - :

SELECT *
FROM
  (VALUES
    (101, 'Bikes'),
    (102, 'Accessories'),
    (103, 'Clothes')
  ) AS Category(CategoryID, CategoryName);

SSDT.

. https://www.simple-talk.com/sql/sql-training/table-value-constructors-in-sql-server-2008/

0

All Articles