Is there a way to get windows task manager data via tsql?

I do not have access to a remote computer with client windows, I only connect their database server via tsql. I need to check which processes take up more memory and inform them. Is there any tsql query to get window processes?

+4
source share
1 answer

Yes it is possible. You can invoke TASKLIST using xp_cmdshell :

exec master..xp_cmdshell 'TASKLIST'

Conclusion:

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. To run xp_cmdshell, you must have the correct permissions and server configuration parameters. Read the comments section on MSDN to understand how to enable xp_cmdshell

+4

Source: https://habr.com/ru/post/1671671/


All Articles