2

I am trying to run an MSSQL script using sqlcmd on Windows 10. The command is something like this:

sqlcmd -S "host" -U "user" -P "password" -d "database" -C -i "script.sql" -I

where the values here are dummy values.

I’m getting the message:

Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Data source name not found and no default driver specified.

I didn’t set up the system, so I don’t know how everything has been installed, but I assume that the sqlcmd was installed with SQLServer Express.

When I check the version, I get:

Microsoft (R) SQL Server Command Line Tool
Version 14.0.2052.1 NT
Copyright (C) 2017 Microsoft Corporation. All rights reserved.

I checked the installed drivers and got:

enter image description here

I don’t know where to go from here. Is it possible to get sqlcmd to use the relevant driver? Why is it looking for version 13 anyway?

asked Jun 10 at 11:40
1

2 Answers 2

9

Is it possible to get sqlcmd to use the relevant driver? Why is it looking for version 13 anyway?

No, each version of SQLCMD is compiled with a specific driver and requires that driver to be available.

I don’t know where to go from here.

Install ODBC 13 or install a later version of the client tool utilities that supports ODBC 17.

answered Jun 10 at 14:07
3
  • Perhaps a later BCP version is already installed but not first in the path. I believe the ODBC 17 version location is C:\Program Files\Microsoft SQL Server\Client SDK\ODBC170円\Tools\Binn\bcp.exe Commented Jun 10 at 21:22
  • It's definitely possible, we'd need their PATH variable to really know. Commented Jun 10 at 21:31
  • See my answer on how I solved this. Commented Jun 14 at 23:10
0

The simplest solution is to use the sqlcmd.exe matched to the installed drviver:

"C:\Program Files\Microsoft SQL Server\Client SDK\ODBC170円\Tools\Binn\sqlcmd.exe" -S "host" -U "user" -P "password" -d "database" -C -i "script.sql" -I

The default sqlcmd on the path was presumably an older one from a separate install.

answered Jun 14 at 8:04
3
  • "I have no idea where that other sqlcmd came from....." We do not even know where it is located, but ignoring it should not be the way to go ... Commented Jun 14 at 11:46
  • To find out where is is do, on a command prompt, this: WHERE sqlcmd.exe. (It will search the PATH and report al locations where the file is found) Commented Jun 14 at 11:47
  • @Luuk You misinterpret the statement. As in the question, I didn’t set up the system, so I don’t know how the other sqlcmd got there. Of course I know where it is, and I know about the WHERE command. Commented Jun 14 at 23:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.