I've been reading about the benefits for all triggers and procedures having "set nocount on" implemented unless you make use of DONE_IN_PROC.
I have a scalar-valued function that is called from an update trigger to calculate the sum of values across multiple tables.
Searching msdn and past articles, I haven't been able to find an explicit example of a function using set nocounton.
What is the impact on a function to include or exclude 'set nocount on'?
Is there a point or code smell in functions that should indicate the addition of set nocount on?
Best Answer
Functions cannot return data to a client so I can't think of any use of
SET NOCOUNT ON
. If you do try to add it a function you'll get an error. SQL Server considers it to cause a side effect:For example, the follow code throws an error: