Re: SET NOCOUNT ON OPTION

From: Philippe [MS] (ptrotin_at_online.microsoft.com)
Date: 10/19/04


Date: Tue, 19 Oct 2004 10:51:32 +0200

You set that value to ON when you do not want to see the row count number
after an insert or update operation.

If your store procedure just SELECT things, do not hesitate to put SET
NOCOUNT ON at the begining of the store procedure.

If you want for example to create a store procedure that make an insert if
the line does not exist and an insert if not, you can do :

UPDATE ...
IF @@ROWCOUNT = 0
BEGIN
    INSERT ...
END

Therefore, you need to have the NOCOUNT set to OFF

Phil.

"Derrick Leggett" <derrickleggett@yahoo.com> wrote in message
news:uc40yFZtEHA.2196@TK2MSFTNGP14.phx.gbl...
> No, the SET NOCOUNT is specific to the procedure and is set at execution
of
> the procedure.
>
> "Leon" <vnality@msn.com> wrote in message
> news:ur62eAZtEHA.1400@TK2MSFTNGP11.phx.gbl...
> > But you always have to set it to NOCOUNT OFF after the action within the
> > store procedure right?
> >
> > "Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message
> > news:OPl5RXYtEHA.2196@TK2MSFTNGP14.phx.gbl...
> > > Personally, I use it at the top of every stored procedure, always. I
> > > never
> > > want the rowcounts returned...
> > >
> > >
> > > "Leon" <vnality@msn.com> wrote in message
> > > news:uZiEERYtEHA.412@TK2MSFTNGP14.phx.gbl...
> > >> When and when not to set SET NOCOUNT ON?
> > >>
> > >> I know what it does but not exactly where and when I want to use it.
> > >>
> > >>
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: SET NOCOUNT ON OPTION
    ... But you always have to set it to NOCOUNT OFF after the action within the ... store procedure right? ... > Personally, I use it at the top of every stored procedure, always. ... > want the rowcounts returned... ...
    (microsoft.public.sqlserver.programming)
  • Re: Very slow after applying sp3!
    ... you would be best served to get rid of the cursor altogether and use set ... > I tried generating the execution plan but failed to do so because the ... I went a step further by diagnosting the store procedure. ... > and condition2 ...
    (microsoft.public.sqlserver.security)
  • Re: Very slow after applying sp3!
    ... What is the difference in the execution of the 2 plans? ... SQL Server MVP ... > store procedure, the execution time needed by the same store procedure is ...
    (microsoft.public.sqlserver.security)
  • Re: Very slow after applying sp3!
    ... Dear Andrew ... I tried generating the execution plan but failed to do so because the ... I went a step further by diagnosting the store procedure. ...
    (microsoft.public.sqlserver.security)