SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Change @@servername in SQL 2005


Change @@servername in SQL 2005

Author
Message
Erin.
Erin.
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2667 Visits: 558
I setup a development server by restoring the system databases from the production server. However, I am now running into a problem with a trigger that is pulling the server name from @@servername. When I select @@servername it returns the production server's name. How can I change @@servername to reflect the development server's name? Both servers are local sql installs. There are no other instances. When I remote into the development server using Management Studio I use what the development server name should be. This name is just not reflected in @@servername.

Can I use the sp_dropserver, sp_addserver? Would doing this have any adverse affects on the databases, jobs, etc?

sp_dropserver
GO
sp_addserver , local
GO

I really don't want to rebuild this development sql server. That would probably involve contacting the vendor, which would means more money.
The_SQL_DBA
The_SQL_DBA
SSCarpal Tunnel
SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)

Group: General Forum Members
Points: 4004 Visits: 935
You can do so by changing the name of your server from windows OS. Then restart SQL server. Your new name should reflect when you run select @@servername again.

Thanks!!

The_SQL_DBA
MCTS

"Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives."
Erin.
Erin.
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2667 Visits: 558
The OS recognizes the development server name correctly. It seems like everything recognizes it correctly except @@servername.
The_SQL_DBA
The_SQL_DBA
SSCarpal Tunnel
SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)

Group: General Forum Members
Points: 4004 Visits: 935
You would need to do this then, won't affect anything else unless you have any jobs that use the old server name. If so you need to updated them with the new server name.

1. sp_dropserver 'old_name'
2. go
3. sp_addserver 'new_name','local'
4. go

Also restart sql server as
net stop mssqlserver
net start mssqlserver

This should do the trick for you

Thanks!!

The_SQL_DBA
MCTS

"Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives."
Erin.
Erin.
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2667 Visits: 558
I also noticed the following logins:
PRODUCTION\SQLServer2005MSFTEUser$PRODUCTION$MSSQLSERVER
PRODUCTION\SQLServer2005MSSQLUser$PRODUCTION$MSSQLSERVER
PRODUCTION\SQLServer2005SQLAgentUser$PRODUCTION$MSSQLSERVER

They should be:
DEVELOPMENT\SQLServer2005MSFTEUser$DEVELOPMENT$MSSQLSERVER
DEVELOPMENT\SQLServer2005MSSQLUser$DEVELOPMENT$MSSQLSERVER
DEVELOPMENT\SQLServer2005SQLAgentUser$DEVELOPMENT$MSSQLSERVER

Would below script fix these as well?
exec sp_dropserver PRODUCTION
GO
exec sp_addserver DEVELOPMENT, 'local'
GO
The_SQL_DBA
The_SQL_DBA
SSCarpal Tunnel
SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)

Group: General Forum Members
Points: 4004 Visits: 935
Did you say you restored the dev server system databases with the backup from production system databases?

Thanks!!

The_SQL_DBA
MCTS

"Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives."
Erin.
Erin.
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2667 Visits: 558
Yes.
Richard M.
Richard M.
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 2688
um....
sp_dropserver will "remove a server from the list of known remote and linked servers on the local instance of SQL Server"..... so it will not affect at all your running instance.

when you run sp_helpserver you are getting production right?

Not sure if only the sp_addserver with the 'local' option will do the trick

_______________________________________________________________________
For better assistance in answering your questions, click here
The_SQL_DBA
The_SQL_DBA
SSCarpal Tunnel
SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)SSCarpal Tunnel (4K reputation)

Group: General Forum Members
Points: 4004 Visits: 935
I dont think you need to restore system databases to make a copy of production. Because Dev and Prod are completely different instances.

Dev and prod need to match with their schema and not system databases.

To avoid any other problems please revert back your dev system databases from backup. Like if you are updating something on Dev box with the criteria of @@servername then it would update your production(only if this job uses an account that exists on prod, but it is a possibility)

Thanks!!

The_SQL_DBA
MCTS

"Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives."
Richard M.
Richard M.
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2926 Visits: 2688
Well, found this http://blogs.techrepublic.com.com/datacenter/?p=192

So apparently the trick with sp_dropserver/addserver and restarting the SQL services does accomplish what you need?

_______________________________________________________________________
For better assistance in answering your questions, click here
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search