Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 decrease a number in column by one

Author  Topic 

Ernie57
Starting Member

27 Posts

Posted - 2007-03-16 : 23:18:10
A want to user a procedure to decrease a number in a col. by 1 each day.

I need some type of operation

then a job has to run the procedure to decrease a number once a day.

I don't know how to go about the operation? I am going to the SQL Query Anylizer to help me run the script to test it. I have in a col. of 201 numbers, and I will subtract 1 from each day from all recorders. I guess you could call this a count down or timer. Does this code work for me?

Thank You,

Insert into newusers (Timer-1)

Select Timer

From newuses


GO

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-16 : 23:44:32
[code]
update u
set Timer = Timer - 1
from newusers u
[/code]


KH

Go to Top of Page

Ernie57
Starting Member

27 Posts

Posted - 2007-03-16 : 23:54:48
quote:
Originally posted by khtan


update u
set Timer = Timer - 1
from newusers u



KH





I just got it working! Thank you,

Ernie
Go to Top of Page

Ernie57
Starting Member

27 Posts

Posted - 2007-03-17 : 00:32:43
quote:
Originally posted by khtan


update u
set Timer = Timer - 1
from newusers u



KH





I created a procedure, but it is not doing anything.

CREATE PROCEDURE [ernie57].[decrement_Timer] AS

update newusers

set Timer= Timer - 1

from newusers Timer
GO

When I try to excute it through SQL Query, it says procedure not found

EXECUTE decrement_Timer
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-17 : 00:53:48
try

EXECUTE [ernie57].[decrement_Timer]



KH

Go to Top of Page

Ernie57
Starting Member

27 Posts

Posted - 2007-03-17 : 13:04:59
quote:
Originally posted by khtan

try

EXECUTE [ernie57].[decrement_Timer]



KH





Thank You,

Ernie
Go to Top of Page
   

- Advertisement -