We are developing an application to do a ‘hearbeat’ test of all our SQL servers (2000, 2005 and 2008), and we’re trying to figure out the minimum permissions necessary on the SQL server to do that. (Platform involved is TBD, but should use a standard connection string).
We are considering using a ‘SELECT @@VERSION’ query, which should be all that is necessary to determine that the sql server is up and running and responding to requests.
What are the minimum SQL permissions necessary to simply connect to the server with a connection string? (We don’t even want to give DataReader, if at all possible) Will those minimum permissions allow me to do the above query? Is there a better/more standard technique for doing this? Will SQL 2000, 2005 and 2008 behave differently?
Just create the login used by the monitor code. On SQL Server 2005 and 2008, you’ll also need
GRANT CONNECT SQL TO (login), otherwise it’s the same.No other rights are needed for
SELECT @@VERSION. Thedb_datareaderyou mention is within a database, not the server level.SQLPing will detect an installation but not always tell you if it’s running.
When do do run
SELECT @@VERSION, make sure that you open and drop a connection. A connecion left open may still work even if the SQL Servr is not accepting new connections.