title: sqlcmd runs script but script does not affect database
body: <p>So we have a .bat file that runs SQL scripts, e.g.</p>
  
  <pre><code>@ECHO --- 03_Case6395_Publication.sql ---  &gt;&gt; dbupt.log
  sqlcmd -U %1 -P %2 -S %3 -d %4 -i 03_Case6395_Publication.sql -k -b &gt;&gt; dbupt.log
  IF ERRORLEVEL 1 GOTO ErrorTag
  </code></pre>
  
  <p>The script runs and gives no errors, but the script doesn't actually affect the database. In the example above, here is what is being run:</p>
  
  <pre><code>IF NOT EXISTS (SELECT 1 FROM [dbo].[syscolumns] WHERE [NAME] = N'MandatoryInList' AND [ID] = object_id(N'Pub_Type'))
  BEGIN
      ALTER TABLE [dbo].[Pub_Type] ADD [MandatoryInList] bit NULL CONSTRAINT [DF_PubType_MandatoryInList] DEFAULT (0)
  END
  ELSE
  BEGIN
      ALTER TABLE [dbo].[Pub_Type] ALTER COLUMN [MandatoryInList] bit NULL 
  END
  GO
  </code></pre>
  
  <p>The script is pretty simple and you would expect it to add a column called MandatoryInList, however it doesn't. The odd thing is there are no syntax errors in the script and when I run it from SQL Server Management Studio, it runs fine. There's no issues with permissions or which user is running the script because there are other scripts that run fine in the batch file.</p>
  
  <p>I should also mention that this runs from a GUI by creating a new process and running it but not showing the command window. But regardless, I've been running the tool like this for months without any issues.</p>
  
  <p>Any ideas?</p>