3

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!

Community
  • 1
  • 1
chama
  • 5,973
  • 14
  • 61
  • 77

2 Answers2

0

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
  • 7,284
  • 5
  • 37
  • 41
  • 1
    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. [ODBC Driver Manager] Connection not open" – chama Mar 08 '10 at 18:49
  • 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 then the datasource exist. What arguments do you give to osql? – Arve Mar 08 '10 at 19:30
  • I gave -L to list the servers, which I would think also doesn't need a data source. – chama Mar 08 '10 at 20:44
0

This utility uses ODBC to communicate with the server.

garik
  • 5,669
  • 5
  • 30
  • 42
  • what do you mean? That just moving osql.exe by itself will allow you to use this utility on a computer without sqlserver? – chama Mar 08 '10 at 18:32
  • I think now all windows has default sql server odbc driver. So try it. – garik Mar 08 '10 at 18:35
  • 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. [ODBC Driver Manager] Connection not open" – chama Mar 08 '10 at 18:50
  • Could you open ODBC manager? Could you find on the System DNS page any sql server drivers? – garik Mar 08 '10 at 18:53
  • {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; – garik Mar 08 '10 at 18:56
  • I think there is a SQL Server listed there – chama Mar 08 '10 at 18:58
  • 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 Mar 08 '10 at 18:59
  • http://blogs.msdn.com/sql_protocols/archive/2008/04/30/steps-to-troubleshoot-connectivity-issues.aspx – garik Mar 08 '10 at 19:18
  • It seems some system problem. Use sqlcmd (it uses OLEDB drivers). osql will be removed in the next versions of sql server. – garik Mar 08 '10 at 19:35
  • I was originally using sqlcmd, but I have to be able to accept an empty password, which sqlcmd doesn't do. – chama Mar 08 '10 at 20:43
  • use windows authentication (–E trusted connection). Of course, your account should have valid permissions on sql server to apply your scripts. – garik Mar 08 '10 at 20:55