In c# projects there is the concept of Preprocessor Directives that allow you to change what code is compiled depending on whether you are building a debug or release version of the app/dll/etc. Is there a similar option for TSQL scripts and DB projects? Specifically, a few of the TSQL scripts I have create dynamic sql statements that do work a remote DB. There is a different remote DB for development and production so the dynamic SQL needs to be different between the two builds. It would be nice to not have to manually update the code every time I switch between deploying to dev and deploying to prod.
Cheers,
Joe
.dbprojprojects are deployed by VS using SQLCMD, so you can use SQLCmd scripting variables.For example:
You can set these in VS under
Properties/Database.sqlcmdvarsin your .dbproj.These variables are then substituted into the .sql scripts as it is deployed.
http://msdn.microsoft.com/en-us/library/ms188714.aspx