29

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.

Any suggestions are appreciated. Thanks in advance!

chama
  • 5,973
  • 14
  • 61
  • 77
  • 4
    Why aren't you just connecting to the server via JDBC? – C. Ross Feb 18 '10 at 18:00
  • 1
    Are you trying to run a sql command remotely from a machine without client tools installed using the client tools exe? Does that violate redistribution rules from the software owner? – William Salzman Feb 18 '10 at 18:02
  • @C. Ross - I don't want to connect to the database. I just want a list of available servers, and then, given a server, a list of available databases @William - I'm not quite sure what you mean by that. – chama Feb 18 '10 at 18:04

3 Answers3

72

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.

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

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

Download the file: 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 Center for "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.

MikeBaz - MSFT
  • 2,938
  • 4
  • 28
  • 57
  • 4
    A better link is http://www.microsoft.com/en-us/download/details.aspx?id=26728 and select the 1033\IA64\SqlCmdLnUtils.msi download. This should install the files to `C:\Program Files\Microsoft SQL Server\100\Tools\Binn` however it might not add them to the system path. – Greg Bray May 30 '12 at 18:49
  • yes, that is the R2 SP1 download, although of course the person doesn't necessarily want IA64. The 2012 version (current now as of my doing this comment) is here: http://www.microsoft.com/downloads/details.aspx?FamilyID=327CDA8D-2AD7-43F9-9746-34AC718F658D&displaylang=ja&displaylang=en – MikeBaz - MSFT Jun 25 '12 at 13:25
  • 2
    Correct. I meant to say the 1033\x64\SqlCmdLnUtils.msi link. Looks like there are anchor links for both the 2008 R2 SQLCMD ( http://www.microsoft.com/en-us/download/details.aspx?id=16978#SQLCMD ) and 2012 SQLCMD ( http://www.microsoft.com/downloads/details.aspx?FamilyID=327CDA8D-2AD7-43F9-9746-34AC718F658D&displaylang=ja&displaylang=en#SQLCMD ) so those may be the best links to refer users to. – Greg Bray Jun 25 '12 at 14:32
  • 5
    I also needed to add the SQL Server Native Client from here: http://www.microsoft.com/en-us/download/details.aspx?id=8824#SNAC – Karl Glennon Aug 14 '12 at 07:25
  • 1
    2012 SP1 feature pack is out and the SqlCmd MSI is reduced from 7MB to 2MB: http://www.microsoft.com/en-us/download/details.aspx?id=35580 – angularsen Jan 07 '13 at 13:58
  • 1
    The original question was "how can I ship sqlcmd with my app so the user doesn't have to have it installed beforehand?" Are there any plans to ship sqlcmd as an actual standalone tool? By standalone here I mean xcopy-deployable, not requiring an installer. – Tim Sparkles Sep 27 '17 at 21:23
  • 1
    In case it helps I found that after copying these 3 files from machine with SQL 2012 into a single folder on a machine where SQL is not installed I can run SQLCMD from command line in that folder just fine for my testing purposes: sqlcmd.exe, batchparser.dll, sqlcmd.rll – Rod Sep 02 '19 at 05:59
0

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

Feature Pack for Microsoft SQL Server 2005 - Nov 2005

Naeem Sarfraz
  • 7,360
  • 5
  • 37
  • 63
-4

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

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

Not sure about redistribution rights

Ron Warshawsky
  • 314
  • 2
  • 11