<tfoot id='m2Skj'></tfoot>
      <bdo id='m2Skj'></bdo><ul id='m2Skj'></ul>
  • <i id='m2Skj'><tr id='m2Skj'><dt id='m2Skj'><q id='m2Skj'><span id='m2Skj'><b id='m2Skj'><form id='m2Skj'><ins id='m2Skj'></ins><ul id='m2Skj'></ul><sub id='m2Skj'></sub></form><legend id='m2Skj'></legend><bdo id='m2Skj'><pre id='m2Skj'><center id='m2Skj'></center></pre></bdo></b><th id='m2Skj'></th></span></q></dt></tr></i><div id='m2Skj'><tfoot id='m2Skj'></tfoot><dl id='m2Skj'><fieldset id='m2Skj'></fieldset></dl></div>
    <legend id='m2Skj'><style id='m2Skj'><dir id='m2Skj'><q id='m2Skj'></q></dir></style></legend>

        <small id='m2Skj'></small><noframes id='m2Skj'>

        使用 ANT SQL 任务调用时 sql 脚本执行失败

        时间:2023-08-21
          <tbody id='5uF84'></tbody>
        <legend id='5uF84'><style id='5uF84'><dir id='5uF84'><q id='5uF84'></q></dir></style></legend>

      1. <small id='5uF84'></small><noframes id='5uF84'>

          • <tfoot id='5uF84'></tfoot>
              <i id='5uF84'><tr id='5uF84'><dt id='5uF84'><q id='5uF84'><span id='5uF84'><b id='5uF84'><form id='5uF84'><ins id='5uF84'></ins><ul id='5uF84'></ul><sub id='5uF84'></sub></form><legend id='5uF84'></legend><bdo id='5uF84'><pre id='5uF84'><center id='5uF84'></center></pre></bdo></b><th id='5uF84'></th></span></q></dt></tr></i><div id='5uF84'><tfoot id='5uF84'></tfoot><dl id='5uF84'><fieldset id='5uF84'></fieldset></dl></div>

                • <bdo id='5uF84'></bdo><ul id='5uF84'></ul>

                  本文介绍了使用 ANT SQL 任务调用时 sql 脚本执行失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  有一个 SQL 文件,其中包含一些 Transact SQL 语句和一些简单的表查询,如下所示:

                  There is a SQL file which contains some Transact SQL statements in it and some plain table queries as follows:

                  IF NOT EXISTS (SELECT * FROM [dbo].[SYSTEM_PROPERTIES] WHERE SYS_PROP = 'ABC')
                  BEGIN
                  DECLARE @SYS_PROP_ID INT;
                  INSERT INTO SYSTEM_PROPERTIES (...,....,...) values ('...','...','...');
                  SELECT    -------;
                  INSERT INTO ------;
                  END
                  GO
                  
                  IF EXISTS (SELECT * FROM [dbo].[TEMPLATE] WHERE TPL_NAME='....' )
                  UPDATE [dbo].[TEMPLATE] SET [...] = 'Y' WHERE TPL_NAME='.....'
                  GO 
                  

                  当我直接在数据库上执行这个脚本时,它工作正常.当通过 ANT SQL 任务调用相同的脚本时,它会失败并显示以下错误:

                  When I execute this script directly on the database, it works fine. When the same script is called through an ANT SQL task it fails with the following error:

                   com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'INT'.
                  at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
                  at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
                  

                  这是 Ant 任务:

                  <sql   driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"   url="---------"
                  userid="--"   password="---"  keepformat="true" print="true" >
                   <classpath>
                      <pathelement location="/lib/sqljdbc4.jar"/>
                      <pathelement location="/lib/ojdbc14.jar"/>
                   </classpath>
                  <transaction  src="${dbscript.location}/dbscript.sql"/>
                  </sql>
                  

                  为什么从 ANT SQL 调用脚本会失败?

                  Why is the script failing when called from ANT SQL?

                  推荐答案

                  我花了很多时间,终于解决了这个问题.通过 ANT SQL 任务调用任何 Transact SQL 语句时,;"不应指定分隔符.从 SQL Management Studio 或 sqlcmd 执行 SQL 语句时,使用这些分隔符不会导致任何问题.另外,正如上面的评论所指出的,通过 ANT SQL 运行脚本时,GO 语句也是不可接受的.

                  After spending a lot of time, I finally was able to resolve the issue. When calling any Transact SQL statements through an ANT SQL task, the ";" delimiters should NOT be specified. Having these delimiters will not cause any problem when executing the SQL statements from SQL Management studio or sqlcmd. Also, as pointed out in the comments above, GO statement is also not acceptable when running the script through ANT SQL.

                  这篇关于使用 ANT SQL 任务调用时 sql 脚本执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无法访问 Sonar MySQL 数据库 原因:java.sql.SQLExcepti 下一篇:ant sql 插入语句在“--"字符串上失败.解决方法

                  相关文章

                  最新文章

                  • <bdo id='coHk0'></bdo><ul id='coHk0'></ul>

                  <i id='coHk0'><tr id='coHk0'><dt id='coHk0'><q id='coHk0'><span id='coHk0'><b id='coHk0'><form id='coHk0'><ins id='coHk0'></ins><ul id='coHk0'></ul><sub id='coHk0'></sub></form><legend id='coHk0'></legend><bdo id='coHk0'><pre id='coHk0'><center id='coHk0'></center></pre></bdo></b><th id='coHk0'></th></span></q></dt></tr></i><div id='coHk0'><tfoot id='coHk0'></tfoot><dl id='coHk0'><fieldset id='coHk0'></fieldset></dl></div>

                  <tfoot id='coHk0'></tfoot>

                  <small id='coHk0'></small><noframes id='coHk0'>

                    <legend id='coHk0'><style id='coHk0'><dir id='coHk0'><q id='coHk0'></q></dir></style></legend>