Is there an open source equivalent to sqlcmd.exe?

  • Is there an open source equivalent to sqlcmd.exe for Windows Server 2008 that will connect to SQL Server 2008 R2? I am looking for a portable .exe that does not require an installer so that I can connect to SQL Server from the command line to debug a server that I do not normally support. If possible, I would like to avoid installing any additional software (including the SQL Server Management Tools) on that server.

  • There is Powershell that can be used instead of sqlcmd but it is not open source, can be used for many things and not only running queries.

  • Here are a couple of hits from CodePlex:

    Mini SQL Query[/url]

    SQLPSX[/url]

    Alternatively you could maybe try installing the management tools on a reference system and copy over sqlcmd.exe and the associated .dlls somewhere you can access them.

    Joie Andrew
    "Since 1982"

  • Superdoc (5/29/2013)


    There is Powershell that can be used instead of sqlcmd but it is not open source, can be used for many things and not only running queries.

    Thanks for the response, but if you are talking about sqlps.exe, it is not installed on this machine. I am trying to avoid installing anything new that might get (incorrectly) blamed for issues in the future.

  • Joie Andrew (5/30/2013)


    Here are a couple of hits from CodePlex:

    Mini SQL Query[/url]

    SQLPSX[/url]

    Alternatively you could maybe try installing the management tools on a reference system and copy over sqlcmd.exe and the associated .dlls somewhere you can access them.

    Thanks for the response. I'll check out your sites. I also found a couple more links that may be promising.

    http://stackoverflow.com/questions/2290903/run-sqlcmd-without-having-sql-server-installed

    http://www.memfix.com/

  • Joie Andrew (5/30/2013)Alternatively you could maybe try installing the management tools on a reference system and copy over sqlcmd.exe and the associated .dlls somewhere you can access them.

    I found an outdated SQL Server 2005 link that identifies (at least some of) the DLLs at http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/784deef7-369a-4bb5-bd37-be7d015b6a4c/, but I cannot find all of them for SQL Server 2008 R2.

    So far, I found the following on a SQL Server 2008 R2 [sic] reference system ( I no longer have a copy of SQL 2005):

    sqlcmd.exe

    sqlcmd.rll

    batchparser.dll (which appears to be named batchparser90.dll in SQL Server 2005 [sic])

    But, I cannot find ATL*.dll (which appears to be named ATL80.dll). Do you know of any documentation that identifies the sqlcmd.exe dll names?

  • there's also several "portable" GUI equivilents of SSMS that would not require an installation;

    the one that i keep on my PortableApps is LinqPad http://www.linqpad.net/?

    not sure if that is an option for you, but i prefer a more robust GUI with multiple query windows over a command line myself

    edit: another one that I have, but don't use is Database Browser portable:

    http://www.etl-tools.com/

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • It looks as if SQLPSX will require a SMO install (which is not "policially suitable" for my situation), although SQLPSX itself appears to have a "manual installation" as an option.

  • shew (5/30/2013)


    It looks as if SQLPSX will require a SMO install (which is not "policially suitable" for my situation), although SQLPSX itself appears to have a "manual installation" as an option.

    it's a pain in the ***, but you can pull all the SMO dll's from the GAC(Windows Global Assembly Cache) so you can include them in any .net app you create that was going to use them;

    i've done that for a schema checker app i wrote that uses SMO, and wanted to include them in the \bin directory of my app so it would be portable with no dependencies

    I *think* this is what you might want:

    Microsoft.SqlServer.ConnectionInfo.dll

    Microsoft.SqlServer.Management.Sdk.Sfc.dll

    Microsoft.SqlServer.RegSvrEnum.dll

    Microsoft.SqlServer.Smo.dll

    Microsoft.SqlServer.SqlClrProvider.dll

    Microsoft.SqlServer.SqlEnum.dll

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell (5/30/2013)


    there's also several "portable" GUI equivilents of SSMS that would not require an installation...

    not sure if that is an option for you, but i prefer a more robust GUI with multiple query windows over a command line myself

    Thanks. I agree. Mostly, I prefer a GUI as well. However, in this case, I really need a command line app that can be scheduled with Task Scheduler.

    [Background information]

    I have a user who is convinced that his third party application is losing connection to SQL Server from a given app server (and the app will not try to reconnect without having its service manually restarted). *No one* else in the shop (which has 20+ instances and 400+) is having similar issues. Unfortunately, this is a high visibility app. If I can get a sustained connection (which writes an audit row to a table once a minute) to work outside of his app on the same application server, I can rule out *server* connectivity issues (and maybe focus more on *application* connectivity issues, which the software vendor should start reviewing).

    I just don't want to install anything on that app server because it has been such a problem child in the past, and I don't want to add to any finger pointing.

  • Lowell (5/30/2013)


    it's a pain in the ***, but you can pull all the SMO dll's from the GAC(Windows Global Assembly Cache) so you can include them in any .net app you create that was going to use them;

    i've done that for a schema checker app i wrote that uses SMO, and wanted to include them in the \bin directory of my app so it would be portable with no dependencies

    I *think* this is what you might want:

    Microsoft.SqlServer.ConnectionInfo.dll

    Microsoft.SqlServer.Management.Sdk.Sfc.dll

    Microsoft.SqlServer.RegSvrEnum.dll

    Microsoft.SqlServer.Smo.dll

    Microsoft.SqlServer.SqlClrProvider.dll

    Microsoft.SqlServer.SqlEnum.dll

    This looks interesting, but I am not a Developer. I do not have the skill set to write such an app. I am proficient in writing PowerShell scripts, but I have not dealt with assemblies in the past.

  • shew (5/30/2013)


    [Background information]

    I have a user who is convinced that his third party application is losing connection to SQL Server from a given app server (and the app will not try to reconnect without having its service manually restarted). *No one* else in the shop (which has 20+ instances and 400+) is having similar issues. Unfortunately, this is a high visibility app. If I can get a sustained connection (which writes an audit row to a table once a minute) to work outside of his app on the same application server, I can rule out *server* connectivity issues (and maybe focus more on *application* connectivity issues, which the software vendor should start reviewing).

    I just don't want to install anything on that app server because it has been such a problem child in the past, and I don't want to add to any finger pointing.

    understood, the background helps a lot. I assume you already looked at the SQL logs to see if anyone is starting and stopping the service or obvious stuff like that.

    developer-wise, since you don't really need SQLCMD but rather an app that connects to a server and writes to a table, this is actually a lot easier.

    It would take me about five minutes to create a console app that connects to SQL server and writes to a logging table on a server, and a local file as well. that app could be called directly or in a scheduled task, or whatever's right for your testing.

    i could provide you with the source code, and you could compile it yourself, if that would get you rolling;

    exe's from strangers are too creepy to accept, no matter who provides it.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell (5/30/2013)


    i could provide you with the source code, and you could compile it yourself, if that would get you rolling;

    exe's from strangers are too creepy to accept, no matter who provides it.

    That would be WONDERFUL! Thanks so much!

  • By the way, http://www.memfix.com/ looked promising, but it requires a "complementary" license. When I sent an email for the license, my email bounced because the vendor's mailbox is full. Hmmm... Probably not a good idea to deal them that vendor anyway...

  • Lowell,

    I just noticed that I didn't answer your question.

    Yes, I have reviewed the logs. Nothing shows up in them.

    A while back, I wrote some code that tracks the number of database connections to each instance over time. This application always has a consistent number of database connections (about 60) until the service is bounced to "fix" the app failure.

    I also wrote code that tracks blocked processes. No processes get blocked. I am not seeing any deadlocks. The app averages less than 10 tps. From a DBA standpoint, the instance looks fine. 8 other named instances run on the same cluster without issue.

    However, the application administrator sees messages in his logs saying that the app is losing connection with SQL Server.

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic. Login to reply