Re: enable TCPIP Protocols by script



BTW, you have to restart the service if you want changes in network
protocols to take effect.

--
Dejan Sarka
http://www.solidqualitylearning.com/blogs/

"Dejan Sarka" <dejan_please_reply_to_newsgroups.sarka@xxxxxxxxxx> wrote in
message news:eRGorcHRHHA.412@xxxxxxxxxxxxxxxxxxxxxxx
How do you enable TCPIP in Protocols for Network Config for the sql
server
2005 and for all the specific IP addressses via T-SQL script.

I do not know for T-SQL, but I guess you can do it with SMO or WMI. Here
is a VBScript script that uses WMI to enlist the protoclos and enable
named Pipes:

' enum protocols and show status
set wmi =
GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement")
for each prop in wmi.ExecQuery("select * " & _
"from ServerNetworkProtocol " & _
"where InstanceName = 'mssqlserver'")
WScript.Echo prop.ProtocolName & " - " & _
prop.ProtocolDisplayName & " " & _
prop.Enabled
next
' enable named pipes
for each changeprop in wmi.ExecQuery("select * " & _
"from ServerNetworkProtocol " & _
"where InstanceName = 'mssqlserver' and " & _
"ProtocolName = 'Np'")
changeprop.SetEnable()
next


--
Dejan Sarka
http://www.solidqualitylearning.com/blogs/




.