I wrote a stored procedure to transfer data from one SQL server to another. Is it possible to have logic at the beginning of the stored procedure to only execute on a certain server?
For example:
If IP!="100.xxx.xxx.xxx" then
RaiseError 'You cannot run this procedure from this server
end if
I know one solution is not deploy the proc to the other server. Just curious, thanks.
G-
Note that
@@SERVERNAMEmay include the instance name information. So you can also say:If you only care about the server (and any instance on that server), you can use a different property, though this returns the node name not the virtual server name in the case of a clustered instance:
If it’s clustered and you want the same code to prevent execution except on any instance in that cluster you can say: