Sql-server – SQL Server ODBC Connection via Command Line

odbcsql serverwindows-xp

I need to create a number of ODBC connections to a MS SQL Server, the clients are mainly XP machines. The connection has to use SQL server authentication – is there a way to do this remotely via command line? I think that this type of authentication may be a stumbling block? Any advice on automating or part automating this type of task would be really appreciated.

Thanks,

Joe

Best Answer

The SQLCMD utility will probably be your best option. From what you've indicated it meets all of the requirements above: command-line, ODBC driver, SQL Authentication. The basic syntax would be something like:

sqlcmd -S <servername> -U <login>

see: sqlcmd Utility

This should work fine in Windows XP but unless you've got SQL already installed on the client machines you will need to manually install SQLCMD and the SQL Native Client. Downloads for distributable packages for both of these can be found here.

Related Topic