Well. Today morning got an unusual requirement to identify the account under which the SQL SErver Agent Service is running. I did identify the undocumented stored procedure that helped me out in the work but also had an interesting finding.
If you want to know the aoount under which the SQL Server is running the try the below mentioed query.
DECLARE @ServiceaccountName varchar(250)
This gives the service account name for the SQL Server.
To identify the service account for the SQL Server Agent use the undoucmented stored procedure as is mentioned below.
Note that there might be some risk factors involved while using undocumented procedures in production.