title: MSSQL execute doesn't throw an error in java
body: <p>I'm trying to EXECUTE a String against a mssql database via java, it works fine if the sql-code is correct or if I'm not using EXECUTE. 
  But if the sql-code in the EXECUTE-string is wrong it does not show any errors.</p>
  
  <p>Although both examples are working fine in the mssql management studio.(both are showing the expected error)</p>
  
  <p>A simple example would be:</p>
  
  <p>WORKING(shows the error):</p>
  
  <pre><code>declare @testvar varchar(255);
  BEGIN
  create table dbo.test1 (testid numeric(10,2));
  ALTER TABLE dbo.test1 ALTER COLUMN testid numeric(15,299);
  END
  </code></pre>
  
  <p>NOT WORKING (does not show any errors):</p>
  
  <pre><code>declare @testvar varchar(255);
  BEGIN
  create table dbo.test1 (testid numeric(10,2));
  SELECT @testvar = 'ALTER TABLE dbo.test1 ALTER COLUMN testid numeric(15,299);'
  EXECUTE (@testvar);
  END
  </code></pre>
  
  <p>Any ideas how to fix that?</p>
  
  <p>Edit 1: (simple java code example, but enough to show this behaviour) </p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  public class QuickSqlExecuteExample {
  public static Connection getConnection(String dbcon) throws SQLException {
      Connection conn = null;
      conn = DriverManager.getConnection(dbcon);
      conn.setAutoCommit(true);
      return conn;
  }
  
  public static void main(String[] args) throws SQLException {
        String dbcon="jdbc:sqlserver://[HOST]:[PORT];databaseName=[DBNAME];user=[USER];password=[PASS];";
        Connection con = getConnection(dbcon);
        String qryString =
                  "declare @testvar varchar(255);"
                  +"\nBEGIN"
                  +"\n create table dbo.test1 (testid numeric(10,2));"
                  +"\n ALTER TABLE dbo.test1 ALTER COLUMN testid numeric(15,299)"
                  //+"\n SELECT @testvar = 'ALTER TABLE dbo.test1 ALTER COLUMN testid numeric(15,299);';"
                  //+"\n EXECUTE (@testvar);"
                  +"\nEND";
        Statement select = con.createStatement();
        select.execute(qryString);
  }
  }
  </code></pre>
  
  <p>Tried drivers: 
  Microsoft SQL Server JDBC Driver 2.0.1803.100 / 4.0.2206.100</p>