简体   繁体   中英

Force @@Servername to return something else in SQL Server

DISCLAIMER: While I'm trying to do this to fool a license enforcement scheme, the company is out of business and I'm only setting up a test server. I don't consider this stealing (as a developer that sells software myself, I wouldn't do that) since I can't pay for another license if I wanted to. However, if the community disagrees, please vote to close this question. Just want to be upfront about this.

We use a server app that, as part of its license enforcement, confirms that "SELECT @@SERVERNAME" matches the license installed on the server. I'm setting up a test instance of this application, but since the license I have is locked to a particular servername, I'm stuck.

Is there a way that I can fool @@SERVERNAME into returning something else? Change the internal name of the server to something different than the DNS name? I know there are SQL Server problems if you rename a server, and maybe I can exploit this to accomplish what I need to (rename the server to the licensed name, install SQL, then rename the server so it doesn't conflict with our production server).

If there is another, non-hacky way to accomplish this (set up an isolated domain, use a virtual server with no network connection, etc), I'd entertain those options as well. What does the community think is the easiest way to get this done?

I'd probably set up a separate machine or a virtual machine named after what the license manager was expecting. A bit tedious to set up, but it would probably get the job done quicker than looking for hacky solutions. Of course, while the install was running I'd still be looking just in case...

It actually looks possible to set the server name property.

SQL 2000: http://msdn.microsoft.com/en-us/library/aa933172(SQL.80).aspx
SQL 2005: http://msdn.microsoft.com/en-us/library/ms174411(SQL.90).aspx
SQL 2008: http://msdn.microsoft.com/en-us/library/ms187944.aspx

You might try using the sp_addserver stored proc on your test server to tell SQL Server that the server name is the one the license is looking for.

From the MS docs ,

SQL Server Setup sets the server name to the computer name during installation. To change the name of the server, use sp_addserver, and then restart SQL Server.

Drop the 'local' linked server, then add it back with the name you want. sp_addserver 'foobar', 'local' will make @@server to return 'foobar'. See kb 303774

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM