title: Msg 102, Level 15, state 1 Line 1 Incorrect syntax near 'n'
body: <p>I have the following query which I am running using a batch file. In the batch file I use the following syntax:</p>
  
  <pre><code>echo populating Application table with values...
  
  SET "installFile=%sqlDir%\Install\DataFiles\Insert_ApplicationNames.sql"
  
  OSQL /n /i "%installFile%" /d%db% /U%user% /P%pswd% /S%serv%
  echo
  echo populated Application table with values in Insert_ApplicationNames.sql
  echo
  </code></pre>
  
  <p>The sql shown below runs without any errors when executed from the SQL Management Studio, but it keeps erroring out when run as a part of the batch script. Could some one help me find what I may be doing wrong here?</p>
  
  <p>Also, the rows do get inserted, but our nightly QA install breaks because of the error thrown by the batch script.</p>
  
  <pre><code>IF NOT EXISTS(SELECT * FROM Application WHERE name = '')
  BEGIN
      INSERT INTO Application
      (Name)
      VALUES
      ('')
  END
  GO
  IF NOT EXISTS(SELECT * FROM Application WHERE name = 'App1.exe')
  BEGIN
      INSERT INTO Application
      (Name)
      VALUES
      ('App1.exe')
  END
  GO
  IF NOT EXISTS(SELECT * FROM Application WHERE name = 'App2.exe')
  BEGIN
      INSERT INTO Application
      (Name)
      VALUES
      ('App2.exe')
  END
  </code></pre>