Showing posts with label second. Show all posts
Showing posts with label second. Show all posts

Monday, March 26, 2012

resetting @@FETCH_STATUS

Hi,
I'm using two cursors in the same proc.
Do I need to reset @.@.FETCH_STATUS before using it to check the status of the
second cursor? If so, how can this be done.
Many thanks for your answers in advance
AntYou're using nested cursors? I am fairly confident you can avoid that...
help us help you by showing us your code and explaining why two cursors are
needed.
"Ant" <Ant@.discussions.microsoft.com> wrote in message
news:1B8B4F75-06D5-4DE6-A614-55AB5DA602AC@.microsoft.com...
> Hi,
> I'm using two cursors in the same proc.
> Do I need to reset @.@.FETCH_STATUS before using it to check the status of
> the
> second cursor? If so, how can this be done.
> Many thanks for your answers in advance
> Ant|||You're on the right track. They weren't nested however, they were in line,
but...
Actually, I just readjusted the code so that I put everything in the first
cursor & now have no need for the second.
Sorry to waste your time but thanks very much for your answer none the less
Ant
"Aaron Bertrand [SQL Server MVP]" wrote:
> You're using nested cursors? I am fairly confident you can avoid that...
> help us help you by showing us your code and explaining why two cursors are
> needed.
>
>
> "Ant" <Ant@.discussions.microsoft.com> wrote in message
> news:1B8B4F75-06D5-4DE6-A614-55AB5DA602AC@.microsoft.com...
> > Hi,
> > I'm using two cursors in the same proc.
> > Do I need to reset @.@.FETCH_STATUS before using it to check the status of
> > the
> > second cursor? If so, how can this be done.
> >
> > Many thanks for your answers in advance
> >
> > Ant
>

Reset Sequential Numbering

I have a table that is updated on a regular interval. I need to set an
overall ID that increments by 1, such as 0001, 0002, etc. I need a second ID
that does similarly, incrementing by 1 (such as 20001, 20002, 20003), but
which also resets to 20001 for each new update interval.
ThanksFor a heavy usage system, this could be costly.
Anyway, you could create an update trigger and increment the columns as
desired.
e.g.
create trigger _u on tb
for update
as
update tb
set colx=right(10001+cast(colx as int),4)
from tb,inserted i
where tb.pk=i.pk
go
-oj
"HollyylloH" <HollyylloH@.discussions.microsoft.com> wrote in message
news:AE05B6DD-30F4-45A3-94D3-AE1AD09BC31F@.microsoft.com...
>I have a table that is updated on a regular interval. I need to set an
> overall ID that increments by 1, such as 0001, 0002, etc. I need a second
> ID
> that does similarly, incrementing by 1 (such as 20001, 20002, 20003), but
> which also resets to 20001 for each new update interval.
> Thankssql