1. start or stop the SQL Agent service in the query analyzer. StartUse master Go Xp_cmdshell 'net start sqlserveragent' Stop Use master Go Xp_cmdshell 'net stop sqlserveragent' Change the service start mode from manual to automatic start Mode Exec xp_cmdshell 'scm-action 7-service MSSQLServer-svcstarttype 2' You can also directly use the command line to execute the content in quotation marks. 2. Causes and handling of abnormal startup On the surface, the SQL Server Agent service is started normally, but the following error occurs when you view the job attributes and job history: Error 14258: SQLServerAgent cannot be started. Please try again later. Possible causes: "Use Windows NT fiber" is selected. The specific cause is unknown. Solution: Enterprise Manager -- Right-click SQL instance -- properties -- Processor -- deselect "use Windows NT fiber" Then restart the SQL service. System Password modified Solution: A. My computer -- control panel -- Management Tools -- services -- Right-click MSSQLServer -- properties -- login identity -- select "Local SYSTEM account" Or: B. my computer -- control panel -- Administrative Tools -- service -- Right-click MSSQLServer -- properties -- login identity -- select "this account" -- select administrator, enter your administrator password in the password and Confirm Password. Differences between the two: Select the first method. The administrator password will be changed later. You do not need to adjust the password (but the system administrator is required to log on to the operating system) An error occurred while the database was DOWN. Solution: Use the installation CD to reinstall the registry, select 'advanced option'-'rebuild registry ', and then proceed all the way ...... /* ** Get whether a service is started Home Haok. Y ** 2004-10-20 Determine whether a service is started based on the results returned by net start. ** Example Declare @ isonworking bit Exec spserviceisonworking 'mssql $ newinstance ', @ isonworking output Select @ isonworking */ Create procedure spserviceisonworking ( @ Servicename varchar (100 ), @ Isonworking bit output ) As Set nocount on Create Table # output ( Ot varchar (100) ) Insert into # output Exec master.. xp_mongoshell 'net start' Set @ isonworking = Case When exists ( Select top 1 1 From # output Where ot like '%' + @ servicename + '%' ) Then 1 Else 0 END Drop table # Output SET NOCOUNT OFF GO The SQL Distributed Relational object (SQL-DMO) Library allows your VB6 applications to automatically interact with the SQL server. This is useful for obtaining information about SQL servers, such as the server status or available servers on the network.
To use the SQL-DMO library, you need to set a reference to the "Microsoft SQL-DMO Object Library. ApplicationObjectListAvailableSQLServersMethod returnsNameListObject that contains a list of available servers on the network. The following code shows how to use this method to fill the list box control: Dim objSQLApp As SQLDMO. Application Dim objNameList As SQLDMO. NameList Dim intCount As Integer Set objSQLApp = New SQLDMO. Application Set objNameList = objSQLApp. ListAvailableSQLServers () For intCount = 1 To objNameList. Count Call List1.AddItem (objNameList. Item (intCount )) Next Another useful object in the SQL-DMO library isSQLServerObject. This object can be used to obtain information about a specific SQL server.ConnectThe method establishes a connection to the database server and accepts three parameters: Database Name, user name, and password. Once the object connection is successful, information about the server can be retrieved: Dim objSQLServer As SQLDMO. SQLServer Set objSQLServer = New SQLDMO. SQLServer ObjSQLServer. LoginSecure = True Call objSQLServer. Connect ("MyServerName", "username", "password ") Debug. PrintobjSQLServer. Name Debug. PrintobjSQLServer. HostName Debug. PrintobjSQLServer. Status Restore the xp_cmdshell |