Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
panthagani
Yak Posting Veteran
58 Posts |
Posted - 2009-12-10 : 08:35:39
|
| I would like to capture the status of WWW service (Started, Running, Stopped) in a sql variable and use the return value to send a mail to myself using SQL 2005 database mail. Here is what I am attempting:DECLARE @result intEXEC @result = xp_cmdshell 'sc query w3svc |find "STATE"' PRINT @resultWhether I use an int or a varchar for @result, it always returns 0.Need ideas on how to capture the status of "sc query <service name>" in sql. Please advise! |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-10 : 08:39:11
|
| DECLARE @result table(data varchar(1000))INSERT INTO @result EXEC master..xp_cmdshell 'sc query w3svc |find "STATE"' SELECT data FROM @resultMadhivananFailing to plan is Planning to fail |
 |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2009-12-10 : 08:44:12
|
| Edit: Nevermind Madiv's was more useful :) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-10 : 09:14:43
|
quote: Originally posted by DP978 Edit: Nevermind Madiv's was more useful :)
No problem. If you have any solution post it MadhivananFailing to plan is Planning to fail |
 |
|
|
panthagani
Yak Posting Veteran
58 Posts |
Posted - 2009-12-15 : 11:18:28
|
| I will try this out and post back. Thank you! |
 |
|
|
|
|
|