views:

46

answers:

3

Simply, I have this SQL statment:

EXEC xp_cmdshell 'tasklist' 

can we order or filter the results by using order by or where?

Thanks,

+1  A: 

not directly. You can insert exec into a temp table or table variable and then sort that though

chuck taylor
+3  A: 

You need to output the results into a temporary table first. This should show you how to do it

http://stackoverflow.com/questions/653714/how-to-select-into-temp-table-from-stored-procedure

jamietre
So, Temp table + OPENROWSET is the solution, let me check it and back.
Wael Dalloul
A: 

I checked jamietre link, and this is the complete answer:

Create table  #MyTempTable
(output varchar(max))

INSERT INTO #MyTempTable
EXEC xp_cmdshell 'tasklist' 

select * from #MyTempTable where output like 'ie%' order by output 

Thanks for all...

Wael Dalloul