Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server project executing multiple script post deploy

I have a SQL Server 2008 DB Project, and want to execute multiple scripts, in order, on post deploy.

I've added a PostDeploy.Sql script to a scripts folder, and marked that as PostDeploy, and that works fine. I'm aware that only one script can be marked as post deploy; so I thought I could do this within the script:

-- Post Deploy stuff
SELECT * FROM MYTABLE
GO

:r RunPostDeploy2.sql
GO

Where RunPostDeploy2.sql is located within the same directory as a link. I've tried copying the file locally, but the issue seems to be the use of :r.

Is it possible to call external scripts from post deploy in this way and, if so, how?

like image 288
Paul Michaels Avatar asked Apr 17 '14 10:04

Paul Michaels


People also ask

Can we have multiple post-deployment script in a database project?

A project can have only one pre-deployment and one post-deployment script.

How do I deploy a SQL database project?

You can configure Web Deploy to run the SQL deployment script that the database project generates, but in order to do this, you need to create a custom WPP targets file for your web application project. This adds a substantial amount of complexity to the deployment process.


1 Answers

You have to turn your script into SQLCMD mode. There is a toolbar button right on the top of the file like this.

enter image description here

Or you can do this by going to

enter image description here

like image 111
ravish.hacker Avatar answered Oct 21 '22 03:10

ravish.hacker