December 22, 2008 at 8:29 am
I'm running an SSIS package to loop through servers and get various information that I can consolidate into one place.
Does anyone know what query would grab the account name that SQL Server and the agent are running under on each box?
I've done a bit of searching but I'm coming up blank.
MCITP, Database Administrator
A hodgepodge of Information Technology and Life
LinkedIn Profile
My Twitter
December 22, 2008 at 10:17 am
December 22, 2008 at 10:22 am
Thanks, that got me started. Now I can just use the same on SQLServerAgent and I'm good to go.
MCITP, Database Administrator
A hodgepodge of Information Technology and Life
LinkedIn Profile
My Twitter
December 23, 2008 at 12:46 pm
Got this from this site I believe way back, this checks to see if it is a named instance and routes the registry accordingly
declare @reg_srv varchar(256),
@reg_agent varchar(256)
if serverproperty('instancename') is null
begin --default instance
set @reg_srv='SYSTEM\CurrentControlSet\SERVICES\MSSQLSERVER'
set @reg_agent='SYSTEM\CurrentControlSet\SERVICES\SQLSERVERAGENT'
end
else
begin --named instance
set @reg_srv='SYSTEM\CurrentControlSet\SERVICES\MSSQL$'+cast (serverproperty('instancename') as sysname)
set @reg_agent='SYSTEM\CurrentControlSet\SERVICES\SQLAgent$'+cast (serverproperty('instancename') as sysname)
end
exec master..xp_regread
'HKEY_LOCAL_MACHINE', @reg_srv, 'ObjectName'
exec master..xp_regread
'HKEY_LOCAL_MACHINE', @reg_agent, 'ObjectName'
go
Andrew
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply