Java 在没有安装 SQL Server 的情况下运行 sqlcmd

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2290903/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 05:44:17  来源:igfitidea点击:

Run sqlcmd without having SQL Server installed

javasql-serversqlcmd

提问by chama

I'm working on a Java program that is calling sqlcmd. It works perfectly on a computer with SQL server installed, but not at all on a computer that doesn't. I want to include the necessary exe and dll files to run this command in my jar. Anyone know which ones I need? I already included batchparser90.dll, sqlcmd.exe, and sqlcmd.dll. It still didn't work.

我正在开发一个调用sqlcmd. 它在安装了 SQL Server 的计算机上可以完美运行,但在没有安装 SQL Server 的计算机上根本无法运行。我想在我的 jar 中包含必要的 exe 和 dll 文件来运行这个命令。有谁知道我需要哪些?我已经包含了 batchparser90.dll、sqlcmd.exe 和 sqlcmd.dll。它仍然没有奏效。

Any suggestions are appreciated. Thanks in advance!

任何建议表示赞赏。提前致谢!

回答by MikeBaz - MSFT

Although it's probably too late for the original poster, for future reference, SQLCMD is freely downloadable, so it's not necessary to purchase SQL Server explicitly for this purpose. Presumably the user has SQL Server with CALs or they wouldn't need SQLCMD in the first place.

尽管对于原始海报可能为时已晚,但为了将来参考,SQLCMD 可以免费下载,因此没有必要为此明确购买 SQL Server。据推测,用户拥有带有 CAL 的 SQL Server,否则他们一开始就不需要 SQLCMD。

In any event, the 2008 R2 download as of my typing this is here:

无论如何,我打字时的 2008 R2 下载在这里:

http://www.microsoft.com/en-us/download/details.aspx?id=16978

http://www.microsoft.com/en-us/download/details.aspx?id=16978

Download the file: 1033\x64\SqlCmdLnUtils.msi

下载文件: 1033\x64\SqlCmdLnUtils.msi

(EDIT 2013-05-01) Please note this is a fairly old release at this point - see the comments for updated links, or search the Microsoft Download Centerfor "Microsoft SQL Server Feature Pack" and pick the release that you prefer - the most recent or the one that matches your SQL Server version in use, as you see fit.

(编辑 2013-05-01)请注意,这是一个相当旧的版本 - 请参阅更新链接的评论,或在 Microsoft 下载中心搜索“Microsoft SQL Server 功能包”并选择您喜欢的版本 -最新的或与您正在使用的 SQL Server 版本相匹配的版本,如您所见。

回答by Naeem Sarfraz

You can download SQLCMD and run as a standalone application. Follow the link.

您可以下载 SQLCMD 并作为独立应用程序运行。按照链接。

Feature Pack for Microsoft SQL Server 2005 - Nov 2005

Microsoft SQL Server 2005 功能包 - 2005 年 11 月

回答by Ron Warshawsky

There is a free tool "SQLS*Plus" (on http://www.memfix.com) which is like SQL*Plus for SQL Server.

有一个免费工具“SQLS*Plus”(在http://www.memfix.com 上),它类似于 SQL Server 的 SQL*Plus。

Very flexible with data formatting (set lines size, pagesize, etc), variables (&, &&), spool, etc

数据格式(设置行大小、页面大小等)、变量(&、&&)、假脱机等非常灵活

Not sure about redistribution rights

不确定重新分发权