SQLTeam.com | Weblogs | Forums

CMD Line ODBC


#1

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?


#2

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?


#3

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


#4

what scripting language are you using?


#5

I'm just using a batch script in Windows.


#6

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/


#7

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


#8

See this:
https://msdn.microsoft.com/en-us/library/ms191294.aspx

this, may help you.


#9

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.


#10

Thanks, but this is for PowerShell?


#11

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

#12

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


#13

OK - got it now:

server=np:hostname

Many thanks to all who helped on this.