These answers (1, 2), using code from this article, recommend using the statement SET NOCOUNT ON
as a temporary placeholder/dummy body for a stored procedure whose body will be overwritten shortly.
Neither those answers nor that article specify why SET NOCOUNT ON
was chosen as the value for the temporary stored procedure body.
My question: Why is SET NOCOUNT ON
a good choice for a temporary stored procedure body which will (if all goes well) be overwritten in a subsequent operation? Is there a better alternative?
Some criteria that come to mind for what might constitute a good temporary / placeholder stored procedure body:
- Fails in an obvious way at runtime if for some reason the subsequent
ALTER
of the stored procedure doesn't happen as planned; - Is easy to understand by future developers maintaining the stored procedure;
- Doesn't add any significant overhead.