user172632
user172632

Reputation:

Suppress SQL Output

When running a SQL query with output to text we typically get back output like this.

AssetID              Occurs
-------------------- -----------

(0 row(s) affected)

Since I am doing thousands of select statements to audit data in my table is there a way to suppress this output on SQL server?

Upvotes: 2

Views: 8544

Answers (2)

David M
David M

Reputation: 72860

If you want to suppress the whole block you've shown then you'd need to do:

SET NOCOUNT ON

...

IF EXISTS(SELECT AssetId FROM Table)
BEGIN
    SELECT AssetId, Occurs FROM Table
END

Upvotes: 5

Andomar
Andomar

Reputation: 238078

Prefix the query with:

set nocount on

to suppress to rowcount messages. You can disable column headers in SSMS, under Tools -> Options - > Query Results -> Results To Text.

As for the rows themselves, you could suppress them by adding a clause like where 1=0, but then I wonder why you select them in the first place.

Upvotes: 2

Related Questions