How not to include sql file content when publishing?

﹥>﹥吖頭↗ 提交于 2019-12-09 06:43:29
Alex M

The below won't work as per expectations:

:r ..\$(Customer)Setup.sql

Instead though, you could use the IF ELSE approach:

IF ('$(Customer)'='customer1')
BEGIN
    :r .\script_customer1.sql
END
IF ('$(Customer)'='customer2')
BEGIN
    :r .\script_customer2.sql
END

After a bit more research I found similar SO question. It turns out the above would not work in case you use GO in your scripts. So could use the below:

IF ('$(Customer)'<>'customer1')
    SET NOEXEC ON

:r .\script_customer1.sql
SET NOEXEC OFF

IF ('$(Customer)'<>'customer2')
    SET NOEXEC ON

:r .\script_customer2.sql
SET NOEXEC OFF
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!