user570715
user570715

Reputation: 639

VS 2010 database project define relative path

below is my folder structure where Script.PostDeployment.sql is saved.

C:\ABC1\ABC2\Dev\Source\ABC3\ABC4\Scripts\Post-Deployment\Script.PostDeployment.sql

I want to define relative path in Script.PostDeployment.sql to run scripts from another folder. below folder has multiple scripts stored.

C:\ABC1\ABC2\Dev\DB\Scripts\Release 0\Sprint1\

will below syntax work?

:r DB\Scripts\Release 0\Sprint1\.\.\.\.\myfile.sql  

Thanks!

Upvotes: 1

Views: 306

Answers (1)

Mat Culpepper
Mat Culpepper

Reputation: 21

The answer is "maybe". The syntax is specific to SQLCMD (:r is a SQL Command directive), but if the script is opened using SSMS, then the relative path is relative to SSMS, not the script that you are running. This can get kind of tricky. If you are only using Visual Studio or SQLCMD (command-line tool) to do the deployment, then this works. If you are going to use any other tool to do the deployment (e.g. Sql Managment Studio), then I would not use relative path.

This has cause great confusion and pain when the Developers say "It works for me" and the deployment/dba team says "it is broken".

Hope this helps.

Upvotes: 2

Related Questions