Does MySQL have an equivalent to SQL Server's SET NOCOUNT ON
statement?
SET NOCOUNT ON prevents the sending of DONEINPROC messages to the client for each statement in a stored procedure.
Using SET NOCOUNT ON can improve performance because network traffic can be reduced. SET NOCOUNT ON prevents SQL Server from sending DONE_IN_PROC message for each statement in a stored procedure or batch of SQL statements.
Now, is set nocount off necessary? No, as any new commands executed will be in a different scope, and by default set nocount off is always in effect. But as stated above in comments, it's considered a good practice, just to explicitly indicate that this setting will return to normal when the proc is finished executing.
SET NOCOUNT ON/OFF statement controls the behavior in SQL Server to show the number of affected rows in the T-SQL query. SET NOCOUNT OFF – By default, SQL Server shows the number of affected rows in the messages pane. SET NOCOUNT ON – We can specify this set statement at the beginning of the statement.
The SET NOCOUNT ON
stops the message indicating the number of rows affected by a Transact-SQL statement from being returned as part of the results.
MySQL doesn't report the number of rows affected by a query, therefore there's no such function.
You can if you like find out about the number of affected rows using the ROW_COUNT() function, right after your query:
DELETE FROM mytable WHERE name="John";
SELECT ROW_COUNT();
There is no equivalent as far as I am aware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With