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 statemen开发者_如何学JAVAts to audit data in my table is there a way to suppress this output on SQL server?
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
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.
精彩评论