October 22, 2012 at 11:35 pm
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'
October 22, 2012 at 11:52 pm
What scripting framework are you using? Powershell, batch files with sqlcmd etc.
Jack Vamvas
sqlserver-dba.com
October 23, 2012 at 3:23 am
i am trying to create .cmd files .
October 23, 2012 at 11:22 pm
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
October 24, 2012 at 1:31 am
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.
October 24, 2012 at 1:56 am
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)
October 24, 2012 at 2:26 am
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.
October 24, 2012 at 4:29 am
any suggession ?
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply