天天看點

SQL語句取得目前SQL Server已連接配接的資料庫和使用者以及所有資料庫資訊

SQL語句取得目前SQL Server已連接配接的資料庫和使用者 

select dbname=case  

  when dbid=0 then null  

  when dbid<>0 then db_name(dbid)  

  end, loginame from master..sysprocesses where hostname is not null

  group by dbid,loginame

所有資料庫資訊

select * from master.dbo.sysdatabases