Vidhya Sagar – Blog One Stop for SQL Server related Queries

15Nov/07

Enable \ Disable Remote connections Via DOS or T-SQL

I've seen in forums seeking to enable \ disable Remote connections via DOS prompt \ T-SQL. I've searched google for this topic and didn't get any article on this topic, so i decided to write a procedure to change Remote connections via T-SQL so that this can be called from DOS.

Enabling \ Disabling Remote connections are nothing but changing registry values in "HKLM\Software\Microsoft\Microsoft SQL Server\MSSQLSERVER\Supersocketnetlib\Protocol", with respect to the values in the registry it enables are disables the protocol for Remote connection.

You can get my remote connection procedure from the path Click Here

1.) Create the procedure in master db
Eg.) sqlcmd -E -S -i"path\remoteconn_dos.sql" -dmaster

2.) You can enable or disable particular protocol as below using the script
The procedure requires two parameter one is protocol name and another is enable or disable bit

Syntax:
Exec master..remoteconn protocol
,1 or 0

where are
np --> Named pipes only
tcp --> TCP\IP only
tcpnp --> Both Named pipes and TCP\IP
1 --> Enable the protocol
0 --> Disable the protocol
Before Enabling Named PipesEg.) sqlcmd -E -S -Q"Exec master..remoteconn np,1"Enabling Named PipesThe above will enable Named pipes protocol3.) Restart SQL services to make the changes effective
Eg.) net start MSSQLSERVER (for default instance) \ net start mssql$instancename (for named instance)
net stop MSSQLSERVER (for default instance) \ net stop mssql$instancename (for named instance)
Restart SQL service to make changes effective4.) You can see from the below screenshot that Named pipes protocols have been enabled, since its showing both protocol because TCP\IP has been already in enabled state

After Named pipes enabled

Hope this article will help you to solve remote connection enabling \ disabling from DOS prompt

VN:F [1.9.4_1102]
Rating: 4.0/5 (1 vote cast)
VN:F [1.9.4_1102]
Rating: +2 (from 2 votes)
Enable \ Disable Remote connections Via DOS or T-SQL, 4.0 out of 5 based on 1 rating
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.