企业管理器-》SQLSERVER组-》你的服务器(没有需注册一个)-》管理-》当前活动

解决方案 »

  1.   

    OK
    如果用ado(asp或asp.net连接),也在这里看吧
      

  2.   

    select * from master..sysprocesses where hostname>''
      

  3.   

    企业管理器-》SQLSERVER组-》你的服务器(没有需注册一个)-》管理-》当前活动和select * from master..sysprocesses where hostname>''有什么区别?
      

  4.   

    一个是图形化工具,一个是 语句。
    另外转载 黄山光明顶的 大作:
    --先生成一个存储过程:
    Create proc usp_getClient_infor 
    as 
    set nocount onDeclare @rc int
    Declare @RowCount intSelect @rc=0
    Select @RowCount=0begin
    --//create temp table ,save sp_who information
      create table #tspid(
     spid int null,
     ecid int null,
     status nchar(60) null,
     loginname nchar(256) null,
     hostname nchar(256) null,
     blk bit null,
     dbname nchar(256) null,
     cmd nchar(32)
      )--//create temp table save all SQL client IP and hostname and login time
    Create table #userip(
     [id]int identity(1,1),
     txt varchar(1000),
    )--//Create result table to return recordset
    Create table #result(
     [id]int identity(1,1),
     ClientIP varchar(1000),
     hostname nchar(256),
     login_time datetime default(getdate()) )
    --//get host name by exec sp_who ,insert #tspid from sp_who,
    insert into #tspid(spid,ecid,status,loginname,hostname,blk,dbname,cmd) exec sp_who declare @cmdStr varchar(100), 
     @hostName nchar(256), 
     @userIP varchar(20), 
     @sendstr varchar(100)
     --//declare a cursor from table #tspid
    declare tspid cursor 
    for select distinct hostname from #tspid  with (nolock) where spid>50 
    for read onlyopen tspid
       fetch next from tspid into @hostName
       While @@FETCH_STATUS = 0
       begin
     select @cmdStr='ping '+rtrim(@hostName)
     
     insert into #userip(txt) exec master..xp_cmdshell @cmdStr 
     
     select @RowCount=count(id) from #userip
     if @RowCount=2 --//no IP feedback package
      begin
      insert into #result(ClientIP,hostname) values('Can not get feedback package from Ping!',@hostName)
      end
     if @RowCount>2 
      begin
      select @userIP=substring(txt,charindex('[',txt)+1,charindex(']',txt)-charindex('[',txt)-1) 
      from #userip
      where txt like 'Pinging%'
      
      insert into #result(ClientIP,hostname) values(@userIP,@hostName)
      end
     select @rc=@@error
     if @rc=0
      truncate table #userip --//clear #userIP table   fetch next from tspid into @hostName
     end close tspid
    deallocate tspidselect * from #result with(nolock)drop table #tspid 
    drop table #userip
    drop table #result
    end
    go--开始查询连接:
    exec usp_getClient_infor