Showing posts with label status. Show all posts
Showing posts with label status. Show all posts

Monday, March 12, 2012

how can i know execution stutus of a stored procedure

hi
i want to know the execution status of a stored procedure . That is i want to know whether the stored procedure was executed succesfully or not.If not i want to get the error messageIt depends on the tasks procedure is going to perform. One way is to use error handling mechanism provided by SQL server.|||you can check the value of @.@.ERROR at the end of your stored procedure and return it.....if there is any error in the stored proc it will be indicated in the value of @.@.ERROR|||you can check the value of @.@.ERROR at the end of your stored procedure and return it.....if there is any error in the stored proc it will be indicated in the value of @.@.ERROR

This is not quite true. If the sproc has multiple steps (for example a select, an insert, another select, and a delete) you will need to check the value of @.@.ERROR after each DML statement, because @.@.ERROR only contains the return value from the last operation.

I encourage developers to save the value of @.@.ERROR into a variable, and then inspect the value of that variable as needed.

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).