Re: Return value from Stored Procedure



1. When you execute a query in Query Analyzer, did you ever notice those "x
rows affected" messages? Well, it's not just QA that those messages get
delivered to. They get returned to ADO as recordsets ...
2. SQL Server does not return the output or return parameter values until
all recordsets generated by the procedure are consumed

Setting NOCOUNT to off prevents those extra resultsets from being generated
and returned.

Light wrote:
Hi Bob,

That does it, but why?

Thanks a billion, you just save my life:).

Bob Barrows [MVP] wrote:
Light wrote:

CREATE Procedure NewCompany
(
@varCompanyName varchar (50) = null,


@RETURN_VALUE int OUTPUT
)
As


You need to add "SET NOCOUNT ON" to this procedure - right here as a
matter of fact.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Re: View contents of a selectcommand including the values of the param
    ... Author, Mentor, Consultant ... Microsoft MVP ... Please reply only to the newsgroup so that others can benefit. ... > test the query in Query Analyzer. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: SQL server Error 80040e14
    ... harsha mogaligundla wrote: ... You would not expect to be able to run this query as-is in Query Analyzer ... Microsoft MVP -- ASP/ASP.NET ... Please reply to the newsgroup. ...
    (microsoft.public.scripting.vbscript)