Write a batch to check and return values from SQL and then run scripts determined by the return

StackOverflow https://stackoverflow.com/questions/21841382

Question

Is it possible to write a batch file that will check and return a value from SQL and run a particular set of scripts depending of the return value from SQL.

For example,

If this returns a version 5 value:

sqlcmd -U *** -P *** -S127.0.0.1 -Q "checkversion.sql" 

Run version 5 scripts, but ignore 1, 2, 3 and 4.

But if this returns a version 6 value:

sqlcmd -U *** -P *** -S127.0.0.1 -Q "checkversion.sql" 

Run version 5 and version 6 scripts but ignore 1, 2, 3 and 4.

Était-ce utile?

La solution

Do it all in TSQL because you can nest stored procedures

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top