1

I'm working with a Database Projecto to deploy databases using "Data pack"

I've set up a paramenter "client", so depending the client I'll run a different set of scripts.

I tried different options, but nothing worked.

I've checked out Conditional logic in PostDeployment.sql script using SQLCMD but no luck

if '$(client)' = 'a' 
:r .\GeneralParams\s01.sql 
:r .\Clients\a\a01.sql 

GO

if '$(client)' = 'b'
:r .\GeneralParams\r01.sql
:r .\Clients\b\b01.sql

Inside every external scripts there are more than 1 GO When you see the output file to be executed, it´s compiling all external files into one.

Does anyone know a way to overcome this o a beautiful workaround

I tried this option:

if '$(client)' = 'a' 
:r .\GeneralParams\s01.sql 
if '$(client)' = 'a' 
:r .\Clients\a\a01.sql 

GO

if '$(client)' = 'b'
:r .\GeneralParams\r01.sql
if '$(client)' = 'b'
:r .\Clients\b\b01.sql

but r01 has more that 1 GO and exits the if clause

2
  • if the external file has only 1 GO the script works, but as I have multiple, the script execute some commands ignoring the IF clause Commented Aug 21, 2017 at 10:20
  • What worked for me, not as elegant as I wanted, is to put the if clauses on each external script Commented Aug 25, 2017 at 11:11

1 Answer 1

0

the way I manage to implement this was doing individual if clauses inside each external file. It's not a pretty but it Worked. I've created an output clause to register all the crud changed made to the database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.