How can I tell if a service is running from SQL?

A. A couple of methods :-

1. Write your own XP to call the NT service API's.

2. Capture and test the NET START output via xp_cmdshell. Example below tests for SQL Agent -

CREATE TABLE #List(Description Char(255))

INSERT INTO #List
EXEC XP_CMDSHELL 'NET START'

IF EXISTS
(SELECT * FROM #List WHERE Description LIKE '%SQLServerAgent%')


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish