Question

When I choose "Publish..." from a Visual Studio database project, it looks like, among other things, it runs the project's scripts on the database, but only the ones that have Build Action set to "Build". In other words, Build Action "None" scripts don't get run on the database as part of a Publish.

I have a database project but I do not have all the database's items in that project. Can I still keep scripts (for example, for stored procedures) in my project and run them on the database? How? If I set them to "Build", I get build errors, because the items they depend on are not in the project. If I set them to "None", they don't run on the database at all. Is there a way to make them run on the database without needing their dependent items? If not, what is the best way to do this?

Was it helpful?

Solution 2

It seems like there is no way to do what I am looking for; that Database projects were meant to have all the dependencies resolved.

OTHER TIPS

You could try setting the build action to none on the script, and then running the script from a post-deployment script.

There can only be one post-deployment script in each database project. You can add it by adding a new item and searching for post-deployment. Within the script, you use the command syntax to execute scripts.

http://www.mssqltips.com/sqlservertutorial/3006/working-with-pre-and-post-deployment-scripts/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top