SET NOCOUNT ON usage

前端 未结 17 1732
抹茶落季
抹茶落季 2020-11-22 05:55

Inspired by this question where there are differing views on SET NOCOUNT...

Should we use SET NOCOUNT ON for SQL Server? If not, why not?

17条回答
  •  醉话见心
    2020-11-22 06:13

    If you're saying you might have different clients as well, there are problems with classic ADO if SET NOCOUNT is not set ON.

    One I experience regularly: if a stored procedure executes a number of statements (and thus a number of "xxx rows affected" messages are returned), ADO seems not to handle this and throws the error "Cannot change the ActiveConnection property of a Recordset object which has a Command object as its source."

    So I generally advocate setting it ON unless there's a really really good reason not to. you may have found the really really good reason which I need to go and read into more.

提交回复
热议问题