Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop SQLServer writing extraneous stuff eg (1 rows affected)

Is there a command I can run inside my SQL script so that it stops outputing information about each operation that gets run?

ie I don't want to see this:

(1 row(s) affected)

(1 row(s) affected)

(1 row(s) affected)
like image 674
Andrew Shepherd Avatar asked Sep 04 '09 03:09

Andrew Shepherd


People also ask

How do I stop rows being affected in SQL Server?

If you do not want to know how many rows were impacted by your SQL Statement, it is a good idea to use SETNOCOUNT ON and turn off the message. In simple words, if you do not need to know how many rows are affected, SET NOCOUNT ON as it will reduce network traffic leading to better performance.

What is 1 row affected in SQL?

When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1.

Which statement is used to suppress the 1 row's affected after executing query statements?

If you want to suppress this message, then you can use the “SET NOCOUNT” statement.

How do I restrict rows in SQL?

If you don't need to omit any rows, you can use SQL Server's TOP clause to limit the rows returned. It is placed immediately after SELECT. The TOP keyword is followed by integer indicating the number of rows to return. In our example, we ordered by price and then limited the returned rows to 3.


2 Answers

Use:

SET NOCOUNT ON

to suppress these messages and use the command below to enable the messages.

SET NOCOUNT OFF
like image 59
x2. Avatar answered Oct 29 '22 04:10

x2.


run this command:

set nocount on
like image 22
Av Pinzur Avatar answered Oct 29 '22 03:10

Av Pinzur