How do I find out if Sql server Agent's login has rights to a DB? How do I find out if the SQL server Agent's login has rights to the target DB, that is the DB on which I will be executing a query ?

Also, how do I find the service that's controlling Agent on the job server and find out the login it's using ?

Is there a query for these things ?

Thanks.
Account

There is no documented way to find out what the current service account for the agent is, at least not before SQL Server 2008R2.

As Jon commented below, in SQL Server 2008R2 SP1 and later you can use this query:

SELECT * FROM sys.dm_server_services;


For versions prior to that you can try one of the following:

Aaron suggested a xp_regread solution here: https://stackoverflow.com/questions/7324407/get-service-account-details-of-the-sql-agent-service
But I currently can't get it to work, and even if you get it to work, there is no guarantee that it still works after the next SQL Server patch was installed.

The easiest would be to start the SQL Server Configuration Manager on the instance's server and look it up in there.

Alternatively you could use the SUSER_SNAME() function to do something like

SELECT SUSER_SNAME() AS LoginName
  INTO tempdb.dbo.AgentAccountTable;


Put this statement into a job, execute that job and then look up the value in that table:

SELECT * FROM tempdb.dbo.AgentAccountTable;




Permissions

As for the permissions: The Agent Server Account must be a member of the sysadmin fixed server role (http://technet.microsoft.com/en-us/library/ms191543.aspx). Therefore it will have access to any database.