Monday, February 27, 2012

How can I get the mssqlserver status ?

How can I get the sql server/msde running status?
[Running/Stopping/Stopped/...]?

API OpenSCManager/OpenService...?
But it seems these function does not work in win98?
And I don;t want to use DMO or WMI

And how can I know whether a specified database is currently in use?

Please help me ,thank youQ1 How can I get the sql server/msde running status?Running/Stopping/Stopped/...?

Q2 And how can I know whether a specified database is currently in use?

A1 On NT 3.x, 4.x, Win 2k, XP, and later one may poll for a list of currently running services e.g.(Net start). On Win Me, 9x and below generally there is not a service implementation per se (generally one would need to poll running processes).

A2 One may check the dbname column of the result set returned by:

exec sp_Who|||thank you|||You can use the SQL-SCM api (however, conflicting documentation exists that it does not work for 2000 even though it is documentated with 2000). Also, you can use the scm.exe utility.|||Originally posted by rnealejr
You can use the SQL-SCM api (however, conflicting documentation exists that it does not work for 2000 even though it is documentated with 2000). Also, you can use the scm.exe utility.


Hello,rnealejr
thank you for your reply

My database is MSDE, I want to find some API that can work under both 2000 and 98.Could you please tell me the API and dll?(I don't want DMO or WMI).I can know SQLServer whether is running through scm -action 3. But how can I get return state in program?


Thank you again|||I believe the dll is named W95scm.dll under the binn directory. There is a header file and library file as well. Which version of sql server are you using ?|||Scm.exe (and the related API) should be easier and more direct to use to ascertain the DBMS operational state. For some reason, I didn't think about the service control manager, (I'm not sure scm supports Sql Server 6.x and earlier installs, but that is not an issue using MSDE).

No comments:

Post a Comment