I have a sproc that has a couple inserts and updates. Only the amount of a specific update needs to be returned. I have tried returning or selecting @@ROWCOUNT but because of other selects in the sproc, it is buried and is difficult to access. Having NOCOUNT ON for the whole proc returns the counts for other inserts and updates as well, obviously. I'm wondering if I can do something like:
SET NOCOUNT ON
-- some inserts, selects, updates
SET NOCOUNT OFF
-- The update I care about
SET NOCOUNT ON
and receive just the count from that update? Thanks in advance.
Why yes, yes you can. That's exactly what SET NOCOUNT is for.
(Did you try this in MS SQL server management studio, or your test environment?)