tags:

views:

765

answers:

3

How to enable tcp/ip through t-sql script on sql server 2008?

A: 

Hi

In order to do that using a t-sql script, you might have to fiddle with the registry settings. I haven't done that before myself using t-sql so can't be of much help. But you may like to look up for xp_instance_regread and xp_instance_regwrite. They are extended stored procedures which allow you to read/write registry values.

Here is an example which might be of some help - http://codebetter.com/blogs/raymond.lewallen/archive/2005/09/12/131869.aspx

The following links should help you locate the whereabouts of TCP/IP settings in the registry. http://support.microsoft.com/kb/315236

http://www.pctools.com/guides/registry/detail/1171/

cheers

Andriyev
Any suggestions as to which registry settings?
Sean Ochoa
Added a couple of links which point to the appropriate registry settings for tcp/ip. I hope it helps you draft the script.
Andriyev
A: 
ALTER ENDPOINT [TSQL Default TCP] STATE = STOPPED;

I reckon though I'm not sure if they fix it to actually work in 2k8. In 2k5 this was a no-op. I don't have a 2k8 instance to test it.

Remus Rusanu
A: 

In order to enable TCP/IP, you'd have to configure Sql Server and open the Windows firewall. I'd think that can't be done from T-SQL.

Here's a link on how to dynamically configure Sql Server using DMO. That works from any language that supports ActiveX, for example VBScript, or any .NET language. http://support.microsoft.com/kb/822642

Here's how to open the Windows firewall programmatically: http://support.microsoft.com/kb/839980

Andomar
:( DMO isn't supported by SQL Server 2008.
Sean Ochoa