如何在存储过程中设置消息 [英] How to Set Message In Stored Procedure

查看:64
本文介绍了如何在存储过程中设置消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在存储过程中设置消息

i want to set message when we make in stored procedure

推荐答案

非常简单。



Very simple.

DECLARE @message NVARCHAR(MAX)
SELECT @message = 'whatever in the world you want it to be.'


如果要显示存储过程中的消息,请使用RAISERROR

If you want to display messages from a stored procedure use RAISERROR
RAISERROR ('Your message', 0, 1) WITH NOWAIT

引用:

这可能会令人惊讶,但使用RAISERROR并不需要有错误的情况。如果给予RAISERROR的严重性级别为0到10,则SQL Server将RAISERROR视为普通消息,而不是完全错误

It may be surprising but using RAISERROR doesn't require that there is an error condition. If the severity level given to RAISERROR is 0 through 10 SQL Server treats the RAISERROR as a plain message and not an error at all

使用带有SQL Server RAISERROR语句的NOWAIT选项 [ ^ ]


这篇关于如何在存储过程中设置消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆