|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:43 AM
Points: 378,
Visits: 897
|
|
i need a automate script to add new sqlinstance name, the script will take the machinename dynamically and we need to pass the instancename value\parameter. The servername below should be "machinename\inst1".
EXEC Sp_addserver 'servername' ,'local'
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 11:44 PM
Points: 25,
Visits: 245
|
|
What scripting framework are you using? Powershell, batch files with sqlcmd etc.
Jack Vamvas sqlserver-dba.com
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:43 AM
Points: 378,
Visits: 897
|
|
| i am trying to create .cmd files .
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 11:44 PM
Points: 25,
Visits: 245
|
|
As long as you have the sqlcmd file installed on the server from which you're executing the code, use the SQLCMD method to log onto the relevant servers. Check SQL Books Online for examples of the SQLCMD If you need to loop through a list of servers , and connect through to various servers , just create a txt file , read from the txt file, and loop and use the SQLCMD for every server.
Jack Vamvas sqlserver-dba.com
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:43 AM
Points: 378,
Visits: 897
|
|
just i need to run the automate script in one server at a time. The script should take the comutername dynamically and addthe servername as "computername\inst" .
EXEC Sp_addserver 'computername\inst' ,'local'
Note: 'inst' is standard.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 12:31 PM
Points: 1,850,
Visits: 984
|
|
Using SSMS you can add dynamically using this script. host_name() function will return the computername.
declare @hostname varchar(200) select @hostname=HOST_NAME()+'\inst' select @hostname
exec sp_addserver @hostname
Malleswarareddy I.T.Analyst MCITP(70-451)
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:43 AM
Points: 378,
Visits: 897
|
|
thanks...
I tried to changed the sqlinstance name with below script but its not changing the sqlinstance name.if i select @@servername then its showing the changed name but it is showing the same old sqlinstance name while connecting to databse engine .
1.Ran the below script.
DECLARE @var1 nvarchar(200) DECLARE @var2 nvarchar(200) SET @var1 = convert(nvarchar(50),@@SERVERNAME) set @Var2= HOST_NAME()+'\inst' EXEC sp_dropserver @var1 EXEC sp_addserver @var2 , 'local'
2.restart the sqlserver instance.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:43 AM
Points: 378,
Visits: 897
|
|
|
|
|