Find out who is connecting to your database – lovely query!

by Xavier Comments: 0

So I needed to figure out which servers are connecting to which databases. That sounds like a complicated thing but it isn’t!

Just run this query (and make sure you have appropriate permissions)

SELECT
loginame, hostname, program_name, DB_Name(dbid), last_batch
FROM
sys.sysprocesses
where hostname <> ”
order by last_batch desc