views:

551

answers:

2

According to the accepted answer to this question, the osql.exe utility can be run as a standalone program on a computer without SQLServer, simply by copying the binary file to the new computer. My question is, however, which other files need to be copied along with osql.exe for it to work?

Thanks so much!

A: 

A good tool for finding the answer to this question is Dependency Walker

And running depends.exe on osql.exe for SqlServer 2008 64 bit reveals the dependencies msvcr80.dll and odbc32.dll. And those DLLs are very likely to be installed already.

Arve
I tried running it (after making sure that both of those dll's were installed), and I got this error: "[ODBC Driver Manager] Data source name not found and no default driver specified. </br> [ODBC Driver Manager] Connection not open"
chama
I am no expert on osql, but this if you provide osql with -S, -U -P arguments it should not need a data source. If you use -D <data source name> then the datasource exist. What arguments do you give to osql?
Arve
I gave -L to list the servers, which I would think also doesn't need a data source.
chama
A: 

This utility uses ODBC to communicate with the server.

igor
what do you mean? That just moving osql.exe by itself will allow you to use this utility on a computer without sqlserver?
chama
I think now all windows has default sql server odbc driver. So try it.
igor
I tried running it (after making sure that both of those dll's were installed), and I got this error: "[ODBC Driver Manager] Data source name not found and no default driver specified. </br> [ODBC Driver Manager] Connection not open"
chama
Could you open ODBC manager? Could you find on the System DNS page any sql server drivers?
igor
{SQL Native Client} is a magic name.use this connection string: Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Trusted_Connection=yes;or this one:Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase; Uid=myUsername;Pwd=myPassword;
igor
I think there is a SQL Server listed there
chama
But I'm not actually using any connection string - I'm just typing in the command prompt `osql -L`. Nothing so complicated as a connection string.
chama
http://blogs.msdn.com/sql_protocols/archive/2008/04/30/steps-to-troubleshoot-connectivity-issues.aspx
igor
It seems some system problem.Use sqlcmd (it uses OLEDB drivers). osql will be removed in the next versions of sql server.
igor
I was originally using sqlcmd, but I have to be able to accept an empty password, which sqlcmd doesn't do.
chama
use windows authentication (–E trusted connection). Of course, your account should have valid permissions on sql server to apply your scripts.
igor