CMD Line ODBC

Good afternoon. First post, so please be gentle.

I have created a script to create an ODBC connection on a PC, as it needs to go on hundreds of PCs for a new software roll-out. The only setting I can't seem to find a command line for is changing the Network Libraries from TCP/IP to Changed Pipes.

Does a command exist for this?

Sorry, don't know the answer to your question, but I'm surprised you want to use Named Pipes rather than TCP/IP - my understanding was that TCP/IP was much preferable ... but perhaps that isn't the case?

Named Pipes is how the vendor of the software require us to set the ODBC up - I was surprised as well!

what scripting language are you using?

I'm just using a batch script in Windows.

I would highly recommend powershell script for that specific issue.
With powershell you can tap into .Net Classes, which takes your scripting to a new level.

check the following link.
https://gbegerow.wordpress.com/tag/powershell-named-pipes/

can you post a snippet of your cmd file where you create the odbc?

See this:

this, may help you.

echo Configure user Data Source
echo.

set dsn_name=APP_NAME
set config_dsn=configsysdsn "SQL Server" "DSN=%dsn_name%|Server=SERVER_NAME|Database=DB_NAME|Trusted_Connection=yes|Language=British"

%windir%\system32\odbcconf %config_dsn%
%windir%\syswow64\odbcconf %config_dsn%

echo Data Source "%dsn_name%" has been configured.
echo.
echo Done.
echo.

Thanks, but this is for PowerShell?

basically in windows the tool you use to change client side protocols is a tool that should come out of the box called
SQL Server Client Network Utility and is

C:\Windows\System32\cliconfg.exe

Any changes you make using this above tool basically writes an entry in your registry at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo

so you can still use bat file and write the values you want to the registry. Create the value manually to see what the registry value data is. Mine looked something like the following.

DBNMPNTW,\\.\pipe\your_server_name\query

both given there:
SQL Server configuration manager and SQL Server Powershell.

OK - got it now:

server=np:hostname

Many thanks to all who helped on this.

1 Like