Search code examples
sqlvisual-studiosqlcmddatabase-project

SQL16010: Incorrect syntaxt after using :r on a database project


I have a database project with the following structure

enter image description here

When I try to publish the profile, the VS compiles de code before and is showing me the following error:

SQL46010: Incorrect syntax near .

I have this option enable for the SQLCMD on my VS configurations

enter image description here

My OneTimeMaster.sql looks also has another error after :r, the code looks like this

:setvar path ".\Sprint 1.11" :r $(path)\Header.sql

How can I make it run just to get the generated script.


Solution

  • I am assuming that your post-deployment or pre-depolyment script are pointing to your OneTimeMaster.sql, on that case if you have your SQLCMD activated, the pre and post deployment sqls will not have any error, but when you try to make a build seems like the other files interpreted by the compiler as regular sql without the SQLCMD command. I tested your scenario and the way that I was able to generate the script was changing the Property Action of the OneTimeMaster.sql and all the subsql files to None. Doing that the generated script had the merge of your Testing1.sql and Testing2.sql. Hope this helps