0

I have tried to assign as SQL query value to a variable so that based on its value I will trigger my ETL job in the shell script.

I tried something like below.

echo off
status='sqlcmd -S {host} -d {db} -U {user} -P {password} -Q "SELECT CASE WHEN fc.config_val< fc.config_val_dev_mysql AND fc.config_val < fc.config_val_prod_mysql THEN 1 ELSE 0 END AS mssql_status FROM flex_configs fc;"';
echo $status

But this is not working.

If the status = 1 then I will trigger the ETL job in the same shell script if not I do nothing. Please suggest me the answer as I am unable to get this script.

Dale K
  • 25,246
  • 15
  • 42
  • 71

1 Answers1

0
status=$(sqlcmd -S {host} -d {db} -U {user} -P {password} -Q "SELECT CASE WHEN fc.config_val< fc.config_val_dev_mysql AND fc.config_val < fc.config_val_prod_mysql THEN 1 ELSE 0 END AS mssql_status FROM flex_configs fc;")
echo $status

You need to put code inside $() like $(my code) or `my code`

Digvijay S
  • 2,665
  • 1
  • 9
  • 21