SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Save result ofa xp_cmdshell command


Save result ofa xp_cmdshell command

Author
Message
anvie
anvie
SSC Eights!
SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)

Group: General Forum Members
Points: 852 Visits: 110
I need to check if my remote network is available every 5 mins. I am thinking to use ping.

Query:
exec master..xp_cmdshell 'ping 192.***.**.*'

Base on the output of this query I will know is my network is still available.

How can I save it in the table then determine from there the reply of the ping.

This practice seems not a good practice. Do I have other option?

Any comment is very appreciated.

Thanks!
Steve Jones
Steve Jones
SSC Guru
SSC Guru (331K reputation)SSC Guru (331K reputation)SSC Guru (331K reputation)SSC Guru (331K reputation)SSC Guru (331K reputation)SSC Guru (331K reputation)SSC Guru (331K reputation)SSC Guru (331K reputation)

Group: Administrators
Points: 331567 Visits: 20112
You can insert..exec into a table.

insert MyTable exec xp_cmdshell ''

but you need to match up the result set with the schema correctly

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
anvie
anvie
SSC Eights!
SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)SSC Eights! (852 reputation)

Group: General Forum Members
Points: 852 Visits: 110
Thank you this works for me BigGrin

Create Table #Output
(
Output varchar(150) default('')
)

INSERT INTO #Output
EXECUTE xp_cmdshell 'ping 192.168.10.1'


SELECT *
FROM #Output
ryancabanas
ryancabanas
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 23
anvie (2/13/2009)
Thank you this works for me BigGrin

Create Table #Output
(
Output varchar(150) default('')
)

INSERT INTO #Output
EXECUTE xp_cmdshell 'ping 192.168.10.1'


SELECT *
FROM #Output


Beautiful. That works well. Thanks!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search