问题
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