與服務器相連的才能列出來sp_who
解决方案 »
- vc6.0下用C连接MYSQL,INSERT时候出现问题
- 请问为什么sql function定义中声明的变量无需初始化?
- 请帮看下如下sql测试代码是想达到什么测试目的,最好帮解释下代码,谢谢
- 关于向数据库插入数据问题
- 这个触发器-应该怎么删除阿??
- 关于sql server2000 字段长度的一个问题
- sql自动产生编号的问题
- 数据库合并的问题
- 在 MSSQL2000 如何让 时间1-时间2 得出天数 急!!!!!!!!!!!!!!!!!
- TRIGGER技术挑战!!!
- 如何在SQL SERVER中随机提取数据!在线等,马上结帖!!!
- 自动增加列id,在没有任何修改情况时ID自已变,这种情况多么?
1,exec master..xp_cmdshell'osql -L'
2,或者
declare @cmdStr varchar(100)
create table #table(id int identity,txt varchar(1000))
create table #t(hostname varchar(100), ip varchar(100))
declare @id int
declare @hostname varchar(100)
set @id = 50
set nocount on
while exists (select top 1 HostName from master..sysprocesses where spid > @id)
begin
select top 1 @cmdStr='ping '+HostName, @id = spid, @hostname = hostname from master..sysprocesses where spid > @id order by spid
insert into #table(txt) exec master..xp_cmdshell @cmdStr
insert #T select @hostname, substring(txt,charindex('[',txt)+1,charindex(']',txt)-charindex('[',txt)-1) from #table where id=2
truncate table #table
end
set nocount off
select distinct * from #t
drop table #table
drop table #t
(local)
LACL-006-W2S
LACL_EXPERIMENTD:\Home\Ncowboy>
D:\Home\Ncowboy>osql -E
1> declare @cmdStr varchar(100)
2> create table #table(id int identity,txt varchar(1000))
3> create table #t(hostname varchar(100), ip varchar(100))
4> declare @id int
5> declare @hostname varchar(100)
6> set @id = 50
7> set nocount on
8> while exists (select top 1 HostName from master..sysprocesses where spid > @i
d)
9> begin
10> select top 1 @cmdStr='ping '+HostName, @id = spid, @hostname = hostname
from master..sysprocesses where spid > @id order by spid
11> insert into #table(txt) exec master..xp_cmdshell @cmdStr
12> insert #T select @hostname, substring(txt,charindex('[',txt)+1,charindex
(']',txt)-charindex('[',txt)-1) from #table where id=2
13> truncate table #table
14> end
15> set nocount off
16> select distinct * from #t
17> drop table #table
18> drop table #t
19> go
hostname
ip
------------------------------------------------------------------------------- ---------------------
------------------------------------------------------------------------ ----------------------------
LACL-008
192.168.103.8(1 行受到影响)
1>