We're in the process of switching from Windows Server 2003 to Windows Server 2008, and we've encountered a frustrating problem:
In the old environment, some developers used sql server 2005 and others used sql server 2008. No problems. Our connection strings all pointed to: localhost/sqlserver. Now, on the new Server 2008 environment, Sql Server 2008 is occasionally resolving the "localhost" which immediately causes the thing to throw an exception.
In sys.servers we've changed the entry to point to localhost/sqlserver using:
exec sp_dropserver 'buckaroo-banzai\sqlserver'
exec sp_addserver 'localhost\sqlserver', local
exec sp_serveroption 'localhost\sqlserver', 'data access', TRUE
and the most frequent offending sql statements look like this (I know it's deprecated form) (note: they aren't the only offenders, just the most common ones):
[localhost\sqlserver].[database].[table].exec sp_executesql blahblah; exec sp_another_sp
The error I'm getting from those is:
Server buckaroo-bonzai\sqlserver not found in sys.servers
switching my sys.servers entry back to buckaroo-bonzai\sqlserver gets this error:
Server localhost-bonzai\sqlserver not found in sys.servers
If everything refers to the sql server as buckaroo-bonzai\sqlserver everything works, but for development, this just isn't an option.
For the record, this hasn't happened before on our windows server 2003 environments, just the new server 2008 environments; any ideas?
possible workarounds I've thought of:
- remove the app.config and web.config files from version control (yech)
- laboriously keep different connection strings in version controlled files (double yech)
- version control the files, but somehow have some unified way of referring to an sql server on a local host (localhost maybe? )= )
- Actually figure out why sql server 2008 is resolving localhost and stop it dead. (yay!)