Friday, February 24, 2012

enable TCPIP Protocols by script

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.> 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\ComputerManage
ment")
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/|||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@.avtenta.si> wrote in
message news:eRGorcHRHHA.412@.TK2MSFTNGP02.phx.gbl...
> 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\ComputerManage
ment")
> 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/
>|||This does not enable the TCPIP, change the enable setting from NO to YES in
the TCP/IP properties. Do you have to do any update statement in WMI? I
haven't used WMI before. I did stop and restart my sql server.
I changed your code from Np to tcp as I think that was for named pipes not
tcp .
Any help would be gratefully received
thanks
"Dejan Sarka" wrote:

> I do not know for T-SQL, but I guess you can do it with SMO or WMI. Here i
s
> 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\ComputerManage
ment")
> 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/
>
>

No comments:

Post a Comment