Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

server rename

Status
Not open for further replies.
Joined
Jun 27, 2001
Messages
837
Location
US
I inherited a sql server that I have always known as cmsphdb5 setup by a former dba. newer Junior dba tries to install LiteSpeed and he gets and error about server name mismatch. I go to QA and run select @@servername and I get
cmdphdb5. Can I sp_dropserver cmdphdb5 and then
sp_addserver cmsphdb5?
 
Change the server name at the OS level first then run this script. Don't forget the DNS if you have it set up. You will have to manually update the originating_server in the msdb.dbo.sysjobs table to the new server name. Also, something about LiteSpeed. If the server name is changed while lite speed is installed you will have to re-install it. That will mean you will also need to get a new key code from them.

Create proc uspRenameServer
@pNewName varchar(256)=null--If NULL we will attempt to rename server to the WINS machine name
/*
Purpose: renames SQL server.
Server: all
*/
AS
Declare @OldName varchar(256)
Declare @NewName varchar(256)
set @OldName=''
select @OldName=isnull(srvname,'') from master.dbo.sysservers where srvid=0
If @pNewName is NULL
Begin
create table #NName (NName varchar (256))
insert #NName exec master.dbo.xp_getnetname
select @NewName=Nname from #Nname
drop table #Nname
End
ELSE If @pNewName is not NULL
Begin
select @NewName=ltrim(rtrim(@pNewName))
End

If @OldName<>@NewName
BEGIN
IF @OldName <>''
BEGIN
print 'Attempting to drop server '+@OldName
Exec master.dbo.sp_dropserver @OldName
END
print 'Attempting to add server '+@NewName
Exec master.dbo.sp_addserver @NewName,'local'
UPDATE msdb.sysjobs SET name = @NewName
END
If isnull(@@Servername,'')<>@NewName
Begin
Print 'Please shut down and restart SQL Server in order to complete renaming.'
End
Else If isnull(@@Servername,'')=@NewName
Begin
Print 'SQL Server is already named ' +@NewName
End
 
We have Litespeed too. Here are a couple of LS KB articles that might help you resolve the problem:




Hope one of them helps. Quest's main support page is


Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top