Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-07-14 : 08:48:59
|
| John writes "How can I return the message that sql server generates when stored procedures are run or conversly, is there a returned message?Regards," |
|
|
humanpuck
Yak Posting Veteran
94 Posts |
Posted - 2006-07-14 : 09:00:40
|
| John if you're executing the procedure in Query Analyzer then it will tell you if your SP failed, otherwise it will tell you how many rows it affected. If you want a specific message you can put a simple print statement at the end of you procedure to send whatever message you want. If the procedure is being run via a Sql Enterprise Mgr job then you can define within the job who to send an error message to when the step of executing that procedure fails. Hope this helps. |
 |
|
|
cmdr_skywalker
Posting Yak Master
159 Posts |
Posted - 2006-07-15 : 02:42:15
|
In your stored procedure, you can use RAISERROR. BOL:quote: Returns a user-defined error message and sets a system flag to record that an error has occurred. Using RAISERROR, the client can either retrieve an entry from the sysmessages table or build a message dynamically with user-specified severity and state information. After the message is defined it is sent back to the client as a server error message.
May the Almighty God bless us all! |
 |
|
|
cmdr_skywalker
Posting Yak Master
159 Posts |
Posted - 2006-07-15 : 02:45:45
|
| That is, if there was an error. If not, use PRINT. To write a log in the NT event log or SQL Server log, use XP_LOGEVENT. You can also create your own table with similar function like the RAISERROR (I use my own table and call it ActivityLog table.)May the Almighty God bless us all! |
 |
|
|
|
|
|