Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

automate script needed Expand / Collapse
Author
Message
Posted Monday, October 22, 2012 11:35 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld 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'
Post #1375838
Posted Monday, October 22, 2012 11:52 PM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC 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
Post #1375839
Posted Tuesday, October 23, 2012 3:23 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld 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 .
Post #1375927
Posted Tuesday, October 23, 2012 11:22 PM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC 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
Post #1376324
Posted Wednesday, October 24, 2012 1:31 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld 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.
Post #1376340
Posted Wednesday, October 24, 2012 1:56 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

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)
Post #1376344
Posted Wednesday, October 24, 2012 2:26 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld 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.
Post #1376353
Posted Wednesday, October 24, 2012 4:29 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:43 AM
Points: 378, Visits: 897
any suggession ?
Post #1376402
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse