Reputation:
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
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
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