views:

148

answers:

1

Hi, I need to create a stored procedure which will get destination IP and then call tracert or ping and then write the result into a sql table so then I can show user the result in a web page . is it possible to do this ? if yes would you please tell me how because I have searched a lot and didn't find a proper solution . and if not what do you suggest ?

Thanks

A: 

Modify as needed -

declare @results table(result varchar(500))

insert into @results
exec sp_executesql N'xp_cmdshell ''ping www.yahoo.com'''

select * from @results

Similarly for tracert

declare @results table(result varchar(500))

insert into @results
exec sp_executesql N'xp_cmdshell ''tracert www.yahoo.com'''

select * from @results
James Conigliaro
Thank you for the solution I write this part for those who want to run query like me and will see the error that xp_cmdshell is not accessible : USE master GO EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE WITH OVERRIDE GO EXEC sp_configure 'xp_cmdshell', 1 GO RECONFIGURE WITH OVERRIDE GO EXEC sp_configure 'show advanced options', 0 GO
Asha