DECLARE @result int

EXEC @result = xp_cmdshell 'net start SQLSERVERAGENT'
IF (@result = 0)
PRINT 'Success'
ELSE
PRINT 'Failure'


EXEC @result = xp_cmdshell 'net stop SQLSERVERAGENT'
IF (@result = 0)
PRINT 'Success'
ELSE
PRINT 'Failure'

相关文章: