Hi all, Is there a simple way to get to the output of an executed xp_cmdshell command ? I have a stored procedure and from inside it I need to run a PING command and to know if it was successful or not. Thanks
create table #tmp(result varchar(255)) insert into #tmp exec master.dbo.xp_cmdshell 'ping yahoo.com' if exists(select * from #tmp where result like '%request timed out%') print 'timeout' else print 'reply' drop table #tmp
You could actually make use > simbol to utput the result into a text file Here is an example xp_cmdshell 'ping www.yahoo.com > c:\test.txt'