Re: Output and return from stored procedure
From: Armando (blba2k_at_nospamyahoo.com)
Date: 03/08/04
- Next message: Pete Ocasio: "Applying the initial snapshot to a merge replicated subscriber"
- Previous message: Prasad Koukuntla: "Re: Output and return from stored procedure"
- In reply to: Prasad Koukuntla: "Re: Output and return from stored procedure"
- Next in thread: Ian: "Re: Output and return from stored procedure"
- Reply: Ian: "Re: Output and return from stored procedure"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Mar 2004 14:20:11 -0500
Right....
something like
Declare @count int
UPDATE....WHERE...
SET @count = @@ROWCOUNT
"Prasad Koukuntla" <prasad.koukuntla@scapromo.com> wrote in message
news:erDqlHUBEHA.3256@TK2MSFTNGP09.phx.gbl...
> Declare another variable and Set the @@ROWCOUNT to this varibale
immediately
> after your update statement.
>
> "Ian" <Ian@net.com> wrote in message
> news:e8$65EUBEHA.3776@tk2msftngp13.phx.gbl...
> > How do I stop @@ROWCOUNT getting wiped out?
> >
> > "Armando" <blba2k@nospamyahoo.com> wrote in message
> > news:u%23RjC2TBEHA.688@tk2msftngp13.phx.gbl...
> > > You have global variables @@ROWCOUNT getting wiped out by the
> > > SET @error = 0 statement. In addition, the CREATE PROCEDURE variable
> > > declarations are incorrect (ie @Varchar(30), @INT). Lastly, why do
> you
> > > need
> > > the pass @ID out again in another variable if you already know what it
> is
> > > when
> > > you pass it in and it won't be changing? I'm thinking you should be
> > using
> > > @Return
> > > as a success/fail.
> > >
> > > "Ian" <Ian@net.com> wrote in message
> > > news:eE7SxlTBEHA.2420@TK2MSFTNGP10.phx.gbl...
> > > > I'm having some trouble getting the right output from a stored
> procedure
> > > > (simple version below). Can someone please tell me why I don't get a
> > value
> > > > in the @Return parameter?
> > > >
> > > > CREATE PROCEDURE TableUpdate
> > > > @ID int,
> > > > @Name @Varchar(30)
> > > > @Return @INT OUTPUT
> > > > AS
> > > > UPDATE TableName SET
> > > > Name = @Name
> > > > where ID = @ID
> > > >
> > > > declare @error int
> > > > set @error = 0
> > > >
> > > > IF(@@ERROR <> 0 )
> > > > BEGIN
> > > > SET @error = @@ERROR
> > > > END
> > > > ELSE
> > > > BEGIN
> > > > IF ( @@ROWCOUNT > 0 )
> > > > BEGIN
> > > > @Return = @ID
> > > > END
> > > > END
> > > > RETURN @error
> > > > GO
> > > >
> > > >
> > >
> > >
> >
> >
>
>
- Next message: Pete Ocasio: "Applying the initial snapshot to a merge replicated subscriber"
- Previous message: Prasad Koukuntla: "Re: Output and return from stored procedure"
- In reply to: Prasad Koukuntla: "Re: Output and return from stored procedure"
- Next in thread: Ian: "Re: Output and return from stored procedure"
- Reply: Ian: "Re: Output and return from stored procedure"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|