How to clear Query Messages?

筅森魡賤 提交于 2020-06-28 14:08:42

问题


How can I clear the Messages buffer in a query?

actually I don't want to see any messages there after my query finishes. consider that, I'm using PRINT statement in my query! also my query may print some error messages with/without RAISEERROR.


回答1:


No there is actually no way to hide custom PRINT messages. You can only hide

  • Number of rows effected (SET NOCOUNT ON;)
  • SQL Warning (SET ANSI_WARNINGS OFF;)

Consider below example

SET NOCOUNT ON;
SET ANSI_WARNINGS OFF;

BEGIN TRY

SELECT 1
PRINT 'Some message'

END TRY 
BEGIN CATCH

    RAISERROR (15600,-1,-1, 'Some Error Message ');
END CATCH



回答2:


Run this Code in your Query Window:

SET NONCOUNT ON

Refer this link for more Detail

SET NOCOUNT ON



来源:https://stackoverflow.com/questions/31647921/how-to-clear-query-messages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!