给你几句代码:
--从系统表中取用户信息(包括用户名,登录名,创建时间,修改时间)
select a.name as UserName,b.name as LoginName,a.CreateDate,a.UpdateDate,a.suid
from master..sysusers a,master..sysxlogins b where b.sid=a.sid and b.name='sa'
go
--查询文件所属用户、文件组
select d.name as owner,c.groupname,a.name,b.name as LogName,a.dbid,a.status,status2,crdate,
a.cmptlevel,a.filename,a.suid,a.version
from master..sysdatabases a,sysfiles b,sysfilegroups c,master..sysusers d
where a.filename=b.filename and b.groupid=c.groupid and a.suid=d.suid
--列出当前所有连接数据库的用户
select spid,kpid,hostname,net_address,net_library,loginame
from master..sysprocesses where kpid<>0