How to suppress terminal output of SQL code

  • Hi folks

    Is there a SQL Server equivalent for Oracle's "set termout off"? This suppresses the output (display) of the SQL commands but not the actual execution.

    If this is possible, can the terminal output be selectively suppressed for certain routines in the SQL script or is the entire script suppressed?

    Thanks in advance,

    Wayne

  • Do you want to suppress results to an application or just within an SSMS session?

  • Just within the SSMS session. Thx.

  • Well this works for any statements that return results. If you want to set this for all SSMS sessions, including new ones, when you open SSMS go to Tools -> Options -> Query Results ->SQL Server (or Analysis Server) -> Results to Grids (or Text) and select "Discard Results After Query Executes". This will set it for all Query Windows opened after you make the change and will keep that setting for SSMS.

    You can also do the same thing to the currently active Query Window by going to Query -> Query Options -> Results -> Grid (or Text).

  • I noticed this option, but figured that it would have global impact. It'd be great if there was a code option to discretionally suppress output within a SQL script/procedure.

    Thx,

    Wayne

  • SET NOCOUNT ON

    ???

    The only DML returning a resultset is SELECT (without INTO).


    N 56°04'39.16"
    E 12°55'05.25"

  • I have the same issue.

    I have an SP that executes a number of SPs used for generating report. What I want is to know how many records would be on the reports if I run them.

    I get the @@rowcount of each called SP, but I want to suppress the actual results set.

    The only way I have come up with so far (but not implemented) is

    Each called procedure needs to take an additional parameter that is only set by the summary SP.

    Each called procedure inserts its results set into a temp table.

    If the summary parameter is set then the select from temp-table is not called, otherwise it is.

    Not nice as each called SP will need to be amended and any new ones will have to follow the same logic

    Obiron

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply