SQL Server中存储过程中的消息 [英] Message in a Stored Procedure in SQL Server

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

问题描述

我将@AccountCode作为参数传递给我的存储过程.如果AccountMaster表中不存在该AccountCode,则必须打印一条消息,说明数据不可用".

I''m passing @AccountCode as the parameter to my stored procedure. If that AccountCode does not exist in the AccountMaster table, the a message must be printed saying ''The data is unavailable''. How do i do this?

推荐答案



你可以试试这个.

Hi,

you can try this one.

IF EXISTS (Select AccountID(Primary Key) From AccountMaster Where AccountCode = @AccoundCode)
BEGIN
  -- your logic
END
ELSE
BEGIN
 -- your message
END


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

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