从 CruiseControl.NET 执行 sqlcmd 时未应用参数

发布于 2024-09-10 02:22:15 字数 675 浏览 6 评论 0原文

好的,这是场景。

CruiseControl.NET(版本:1.5.7256.1)运行一个项目来重建数据库。 CruiseControl.NET Windows 服务以我们为 CC.NET 创建的 Windows 用户身份运行。项目中有几个任务,但它们都运行良好。但是,运行的任务之一是我用 C# 编写的基于控制台的实用程序,它生成一个批处理文件,然后通过 .NET Process 类的实例运行它。

批处理文件已正确生成,并且该过程在 C# 中运行良好。但是,运行的批处理文件将运行 SQLServer(版本 2005 SP3)的 sqlcmd 命令行实用程序。 sqlcmd 按预期运行,但 sqlcmd 的选项之一永远不会应用... -I(打开带引号的标识符)。

例如,

sqlcmd -U %1 -P %2 -S %3 -d %4 -i someScript.sql -k -b -I  >> %LogFileName%

奇怪的是,如果我从持续集成服务器上的命令提示符运行它,它会应用 -I 来运行。

我很困惑。我会理解 sqlcmd 是否因为执行该进程的用户没有足够的权限而失败,并且我会理解如果 SQLServer 身份验证失败,SQLServer 端是否会出现问题,但对于它工作但不将选项应用于 sqlcmd 是令人费解的。

OK, so here's the scenario.

CruiseControl.NET (Version : 1.5.7256.1) runs a project to rebuild a database. The CruiseControl.NET windows service is running as a windows user we created for CC.NET. There are several tasks in the project but they all run fine. However, one of the tasks that runs is a console based utility I wrote in C# that generates a batch file and then runs it via an instance of the .NET Process class.

The batch file is generated properly and the process runs fine in C#. However the batch file that runs, runs the sqlcmd command line utility for SQLServer (Version 2005 SP3). sqlcmd runs as expected, but one of the options for sqlcmd never gets applied... -I (turning quoted identifiers on).

e.g.

sqlcmd -U %1 -P %2 -S %3 -d %4 -i someScript.sql -k -b -I  >> %LogFileName%

The odd thing is if I run this from a command prompt on the continuous integration server, it runs with -I being applied.

I'm very confused. I'd understand if the sqlcmd failed because the user executing the process didn't have enough privileges and I'd understand if something went wrong on the SQLServer side if the SQLServer authentication failed, but for it to work but not apply an option to sqlcmd is mystifying.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柏林苍穹下 2024-09-17 02:22:15

难道是因为-I是最后一个参数?也许那里缺少空格或其他东西..您尝试过切换参数顺序吗?

(另外,为什么要运行创建批处理文件并调用它的 C# 控制台应用程序?cc.net 本身无法运行此文件吗?)

Could it be it's because -I is the last parameter? Perhaps there's a missing space there or something.. have you tried switching parameter order?

(also, why are you running a C# console app that create a batch file and the invokes it? Can't cc.net run this file itself?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文