Tuesday, June 9, 2009

Name of the server on which a query is executing

Sometimes while executing a batch of queries it is a must to find out what server the batch is executing on. e.g. while creating a linked server you might not want to create a linked server for the local server.
This can be achieved by querying the sys.servers table and check for the server with server_id 0.
so the query to do this is

select name from sys.servers where server_id = 0

Happy coding...

~Abhishek

No comments: