title: how to run sql command in chef
body: <p>I want to run the below MSSQL command from a Chef cookbook on a windows server.</p>
  
  <pre><code>update RP2.rp2.USR02 SET UFLAG='0' WHERE BNAME='DDIC' AND MANDT='001'
  </code></pre>
  
  <p>If I run the chef-client from command prompt, its updating the DB. But I want this to work, when I run the Chef service instead of directly running the chef-client from command prompt, which is not working. I tried below code</p>
  
  <pre><code>path = File.join('D:', 'Program Files', 'Microsoft SQL Server', '110', 'Tools', 'Binn')
  
  
   execute 'run_sql_update_db' do
      cwd path
      command "SQLCMD.EXE -Q \"UPDATE RP2.rp2.USR02 SET UFLAG='0' WHERE BNAME='DDIC' AND MANDT='001';"
   end
  </code></pre>
  
  <p>This is not showing any error.</p>
  
  <p>I have tried with .sql script as well. Below the code I tried</p>
  
  <pre><code>  execute 'run_sql_update_db' do
      cwd path
      command "SQLCMD.EXE -i D:\\TEMP\\update_db.sql"
    end
  </code></pre>
  
  <p>The update_db.sql have below content</p>
  
  <p><code>update RP2.rp2.USR02 SET UFLAG='0' WHERE BNAME='DDIC' AND MANDT='001'</code></p>
  
  <p>Please help.</p>