Is there any way to get windows task manager details through tsql?

ぃ、小莉子 提交于 2019-12-20 01:13:47

问题


I do not have access to the client's windows remote machine,I connect their database server through tsql only.I need to check what processes taking more memory and inform them. Is there any tsql query to get windows processes?


回答1:


Yes, it is possible. You can call TASKLIST command via xp_cmdshell:

exec master..xp_cmdshell 'TASKLIST'

Output:

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0                            0          4 K
System                           4                            0        140 K
smss.exe                       212                            0        956 K
csrss.exe                      332                            0      5,560 K
.....
sqlservr.exe                  1492                            0     92,012 K
sqlservr.exe                  1532                            0     95,928 K
.....

Note: you should have the correct permissions and Server configuration options to run xp_cmdshell. Read the remarks section in MSDN to understand how to enable xp_cmdshell



来源:https://stackoverflow.com/questions/42640548/is-there-any-way-to-get-windows-task-manager-details-through-tsql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!