gds通用软件开发系统

导航

mssql获取excel进程数量的sql

if object_id('tempdb..excel') is not null drop table tempdb..excel
create table tempdb..excel
(outstr varchar(500))

insert into tempdb..excel
exec master..xp_cmdshell 'TASKLIST /FI "Imagename eq excel.exe"'

select case when count(*)>=5
then  '目前'+cast(count(*)-4 as varchar(20))+'个excel进程'  else '无进程'  end
from tempdb..excel

 

 

注意有些电脑上无法执行tasklist ,默认在system32目录下tasklist.exe这个文件,复制过去就可以

显示这个是因为system32下没有tasklist.exe这个外部命令,你可以从其他机器或网络上下载放到system32下。
如果你在system32下可以找到tasklist.exe,那就是系统环境变量有问题,
你可以在我的电脑-属性-高级-环境变量中 设置path值 添加c:\windows\system32。
 

posted on 2010-12-31 20:00  gds通用软件开发系统  阅读(242)  评论(1编辑  收藏  举报