Check if SQL Server Agent is running from code? - sql-server

How can I determine from code, if SQL Server Agent is running - using SMO?
I would think there was a property on the JobServer class, but I can't find anything.
Powershell is not an option.

Check if windows service (SQL Server Agent) is running...

Related

SQL Server PowerShell dir

I started to learn PowerShell. When I run
PS SQLSERVER:\sql> dir
I got this error:
WARNING: Could not obtain SQL Server Service information. An attempt to connect to WMI on 'DESKTOP-EGEQJFS' failed with the following error:
An exception occurred in SMO while trying to manage a service.
Failed to retrieve data for this request.
Invalid class
Any ideas?
It looks like you're using the SQL Server version of PowerShell. This is intended for performing advanced administration tasks with SQL Server and is not intended as a learning environment.
You're getting the "WARNING: Could not obtain SQL Server Service information" error message because the computer you're attempting to run the SQL Server PowerShell on does not have SQL Server installed or your Windows User account does not have permission to access the SQL Server's configuration data using WMI. If you have SSMS (SQL Server Management Studio) or SSDT (SQL Server Development Tools) installed you won't necessarily have SQL Server installed.
If you want to learn how to use PowerShell then use the Windows PowerShell, not the SQL Server PowerShell. You can find the Windows PowerShell under Start Menu > Windows PowerShell > Windows PowerShell. I recommend using the "PowerShell ISE" tool because it provides a GUI with a listing of all loaded Cmdlets.

Remote Procedure call failed with sql server 2008 R2

I am working with SQL Server 2008 R2. I am unable to connect to my database remotely. I got the following error.
A network-related or instance-specific error occurred while establishing a connection
to SQL Server. The server was not found or was not accessible. Verify that the instance
name is correct and that SQL Server is configured to allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I have checked the SQL Server properties and I enable the Allow remote connections.
I have checked the Service manager and SQL Server service are running.
I have checked the configuration manager, I can't see any services under SQL Server Services
and it shows Remote Procedure call failed
So please guide me.
Open Control Panel > Administrative Tools > Services > Select Standard services tab (under the bottom) > Find start SQL Server Agent
Right Click and select properties,
Startup Type : Automatic,
Apply, Ok.
Done.
I just had the same issue and was able to solve it by installing Service Pack 1.
This error occurs only after I have installed the Microsoft Visual Studio 2012 setup in my work machine.
Since it is being a WMI error, I recompiled the MOF file –> mofcomp.exe "C:\Program Files (x86)\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof"
I also un-registered and re-registered the sql provider DLL –> regsvr32 "C:\Program Files (x86)\Microsoft SQL Server\100\Shared\sqlmgmprovider.dll" but issue not resolved.
Solution:
I have applied SQL Server 2008 R2 SP2 on my SQL 2008 R2 instance and that fixed the issue with Sql Server Configuration Manager. You can download setup from here... http://www.microsoft.com/en-us/download/details.aspx?id=30437 .
After trying everything between Stackoverflow and Google, I finally found a solution : http://blogs.lessthandot.com/index.php/datamgmt/dbadmin/remote-procedure-call-failed/
TL;DR :
If you are (or were) running multiple versions of SQL Server on your machine, that Configuration Manager shortcut on your start menu might be pointing to an older version, which it shouldn't be. It was pointing to an old Sql Server 2008 instance in my case.
The solution was to :
Go to either C:\Windows\SysWOW64 or C:\Windows\System32, depending on your system.
Look for an executable called SQLServerManagerXX.msc, and run the latest version if you have multiple ones. In my case, I had both SQLServerManager11.msc and SQLServerManager10.msc, where the 10th gave the error, and the 11th worked perfectly.
I can't comment yet, but make sure you made all the checks in this quide: How to enable remote connections in SQL Server 2008? It should work fine if all steps are made.
Upgrade your SQL Server to SP3
You can install it from:
http://www.microsoft.com/en-us/download/details.aspx?id=27594
This error appears to happen when .mof files (Managed Object Format (MOF)) don’t get installed and registered correctly during set-up. To resolve this issue, I executed the following mofcomp command in command prompt to re-register the *.mof files:
mofcomp.exe "C:\Program Files (x86)\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof"
This one worked for me
start SQL Server Agent from the command prompt using:
SQLAGENT90 -C -V>C:\SQLAGENT.OUT
You might need to install SQL Server 2008 SP3.
SQL Server 2008 Service Pack 3
SQL Server 2012 Configuration Manager WMI Error – Remote Procedure call failed [0x800706be]
I got the samilar issue, while both SQLServer and SQLServerAgent services are running. The error is fixed by a restart of services.
Server Manager > Service >
SQL Server > Stop
SQL Server > Start
SQL Server Agent > Start
Open Control Panel
Administrative Tools
Services
Select Extended services tab
Find SQL Server(MSSQLSERVER) & SQL Server(SQLEXPRESS)
Stop these services and Start again (from the start & stop button displayed above)
Done.

The remote procedure call failed with on MSSQL Server 2008

Recently, I have installed MSSQL Server 2008 Express.
Every time I try to enable "SQL Server Agent (SQLEXPRESS)", I got this error message:
WMI Provider Error: "The Remote procedure call failed".
I have tried to search for a solution but I have found some solutions and tried them all but It is still not working. Do you have know a good solution for this?
In addition, what is SQL Server Agent? do we really need it?
This is a bit strange.
One of the restrictions of the free SQL Server Express (compared to the bigger editions) is that it has no SQL Server Agent.
So you shouldn't even be able try to enable SQL Server Agent, because your edition doesn't support it!
However, I have SQL Server 2008 Express installed as well, and I never cared to take a look if the SQL Server Agent service is listed on my machine.
I just looked on my machine: it is there, it's called "SQL Server Agent (SQLEXPRESS)" exactly as yours, and I'm even able to start it.
I didn't expect that!
But it's not visible in SQL Server Management Studio, so I can't create any jobs (and I expected that).
Apparently Microsoft restricted the use of SQL Server Agent in the Express edition not by omitting the service at all, but by making it invisible in Management Studio.
So my actual answer is this:
Don't waste time by trying to start SQL Server Agent.
You don't need it to run the database, and you can't use it anyway even if you can get it to run.
SQL Server Agent is used for Job Scheduling, amongst other things.
If you don't know what it is, you probably don't need it ;) It's not necessary for the standard SQL Server RDBMS functionality.
I can't speak specifically to the error you're seeing.

SQL Server Agent stop, start, pause, restart buttons are all disabled

Can anyone know why all the buttons are disabled ?
I am trying to create a Job on SQL Server 2008 R2 Express.
Thanks.
I do not believe the SQL Agent is included in SQL Express. With SQL 2008, MS started including the creation of the service but I believe it is disabled by default and cannot be started.
Jeff is correct, SQL server agent is not included in any of the express editions of SQL server. You can however still schedule tasks using a combination of sqlcmd and windows task scheduler. It’s a bit crude but does the job!
Check this out
Go to run type services.msc
Right click on the SQL Server Agent (MSSQLSERVER)
Then check in the properties your startup type might be disabled change it to automatic or manual and try again it will enable the start option

Start Sql Server Agent

I just got SQL Server 2008 Enterprise edition, but I can't start the Agent XPS service. I looked over surface area configuration and tried to change the service start mode from Disabled to Automatic (in the SQL Server configuration manager) and there I generated an error message:
The remote procedure cannot be completed.
The error code is 0X800706be, I didn't change any setting and I'm connecting to the server with windows authentication, what do I need to do to fix this?
Make sure that the logon account for the SQL Agent service has the "Logon as a service" rights specified in "Security Settings\Local Policies\User Rights Assignment\"
Do you have 2005 installed also? There are too many common things like DLL(s) that are being used by both 2005 and 2008 to have them both running on the same machine and not have any problems.

Resources