select client_net_address, session_id from sys.dm_exec_connections where net_transport = 'TCP
This may search only for the "TCP" but there were "namepipe" as well which may unknown to me..
http://www.sqlservercentral.com/Forums/Topic1010535-391-1.aspx#bm1010543
To get the database ID
SELECT SUBSTRING(db.name,1,30) AS Database_Name,
db.database_id AS Database_ID
FROM sys.databases db
ORDER BY Database_ID;
go
To get the database ID
SELECT SUBSTRING(db.name,1,30) AS Database_Name,
db.database_id AS Database_ID
FROM sys.databases db
ORDER BY Database_ID;
go