SQL Stuff

Set All SQL Ports From SSMS

Some people feel the only option for setting the ports is from the server directly. You don’t need to literally logon to the Windows Server where SQL Server resides in order to set the port. You can use SSMS as usual provided you have an account that has admin rights on the Windows Server where SQL is installed.

If you do; simply run this:


use master;
set nocount on
exec sp_configure 'show advanced options', '1'; reconfigure
exec sp_configure 'xp_cmdshell', '1'; reconfigure
go

exec master..xp_cmdshell
'@echo SETTING ALL STANDARD SQL PORTS
@echo SQL SERVICE PORTS 1433
netsh advfirewall firewall add rule name="SQL Server" dir=in action=allow protocol=TCP localport=1433 @echo DEDICATED ADMIN PORTS 1434
netsh advfirewall firewall add rule name="SQL Admin Connection" dir=in action=allow protocol=TCP localport=1434 @echo SERVICE BROKER PORTS
netsh advfirewall firewall add rule name="SQL Service Broker" dir=in action=allow protocol=TCP localport=4022 @echo TSQL/RPC port 135
netsh advfirewall firewall add rule name="SQL Debugger/RPC" dir=in action=allow protocol=TCP localport=135 @echo SSAS PORTS
netsh advfirewall firewall add rule name="Analysis Services" dir=in action=allow protocol=TCP localport=2383 @echo Enabling SQL Server Browser Service port 2382
netsh advfirewall firewall add rule name="SQL Browser" dir=in action=allow protocol=TCP localport=2382 @echo SETTING STANDARD APP PORTS IF ANY
@echo HTTP port 80
netsh advfirewall firewall add rule name="HTTP" dir=in action=allow protocol=TCP localport=80 @echo HTTP port 25
netsh advfirewall firewall add rule name="SMTP" dir=in action=allow protocol=TCP localport=25 @echo SSL port 443
netsh advfirewall firewall add rule name="SSL" dir=in action=allow protocol=TCP localport=443 @echo SQL BROWSER PORTS
netsh advfirewall firewall add rule name="SQL Browser" dir=in action=allow protocol=UDP localport=1434 @echo MULTICAST UDP PORTS
netsh firewall set multicastbroadcastresponse ENABLE'

Hope this is useful.

Advertisements

Categories: SQL Stuff

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s