Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
DBASlut
Yak Posting Veteran
71 Posts |
Posted - 2006-08-15 : 13:43:47
|
How can i find out exactly what account SQL Server is running as?Don't say look at Services as Services on displays 'login as' which doesn't say what its running as at the moment, just what it will run as when it is re-started. |
|
druer
Constraint Violating Yak Guru
314 Posts |
Posted - 2006-08-15 : 15:22:09
|
It may or may not help, but likely the job engine is running under the same account and you could select against sysprocesses to see which user acct/process is running the SQLAgent - Alert Engine. That does assume that the same account is used for both.Hope it helps,DaltonBlessings aren't so much a matter of "if they come" but "are you noticing them." |
 |
|
schuhtl
Posting Yak Master
102 Posts |
Posted - 2006-08-15 : 15:37:38
|
declare @service varchar(100) declare @key varchar(100) declare @value varchar(100) -- Find the SQLServer account set @service = case when @@servicename = 'MSSQLServer' then 'MSSQLServer' else 'MSSQL$' + @@servicename end set @key = 'System\CurrentControlSet\Services\' + @service execute master.dbo.xp_regread 'HKEY_LOCAL_MACHINE', @key, 'ObjectName', @value OUTPUT print @service + ': ' + @value -- Find the SQLServerAgent account set @service = case when @@servicename = 'MSSQLServer' then 'SQLServerAgent' else 'SQLAgent$' + @@servicename end set @key = 'System\CurrentControlSet\Services\' + @service execute master.dbo.xp_regread 'HKEY_LOCAL_MACHINE', @key, 'ObjectName', @value OUTPUT print @service + ': ' + @value |
 |
|
DBASlut
Yak Posting Veteran
71 Posts |
Posted - 2006-08-15 : 16:27:50
|
schuhtl, thanks for the t-sql code but that only reads what the service is set to. I tested it with an instance that is running as LOCAL and it returns LOCAL, however I went to the service and set it to the DOMAIN acct sonydb\sqlservice BUT didn't re-start service and the t-sql returned sonydb\sqlservice.It reads what is in the registry, but not what the Server Engine is currently running as.. |
 |
|
DBASlut
Yak Posting Veteran
71 Posts |
Posted - 2006-08-15 : 16:30:15
|
quote: Originally posted by druer It may or may not help, but likely the job engine is running under the same account and you could select against sysprocesses to see which user acct/process is running the SQLAgent - Alert Engine. That does assume that the same account is used for both.
Thats the thing druer, i know SQL Agent is running under the desired domain account, plus I can stop this whenever and re-start. The Server engine itself is what I'm trying to find out. What acct is it currently running under. I can go to the services and change it to use the domain account WHEN it re-starts but only when it re-starts. Also the post by schuhtl only reads what the registry is set to when you adjust the login info.. |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-08-15 : 18:00:44
|
This should give you the info you need, depending on the server OS you are running. You must be sysadmin for this to work correctly.create table #t ( cmd_out VARCHAR(400))insert into #t exec master.dbo.xp_cmdshell 'set'select * from #t where cmd_out like '%user%'drop table #t CODO ERGO SUM |
 |
|
DBASlut
Yak Posting Veteran
71 Posts |
Posted - 2006-08-18 : 15:26:22
|
Muchas Gracias Michael, that did the trick.. |
 |
|
|
|
|
|
|