pshekhar
pshekhar

Reputation: 166

How to change data in sql depending upon date?

I have to set the value of column or 'Y' to 'N' automatically after a certain period.Like after 30 days I want change status column 'Y' to 'N' in sql.

Upvotes: 0

Views: 123

Answers (3)

murali krishna
murali krishna

Reputation: 67

We are not clear.if you have modified column on that table and update the that columns as sysdate.

Upvotes: 0

Nick Wyman
Nick Wyman

Reputation: 1158

That sounds like you need to have a job ran that goes through these records and updates the value of this column.

How I would do it is create a datetime stamp column on the same table, which is populated when the value in your "Y" or "N" column is updated. A job would be ran, say once a day, that checks that time stamp and adjusts your column's value accordingly. It then would wipe out the timestamp to make sure it doesn't get caught again.

Upvotes: 0

murali krishna
murali krishna

Reputation: 67

as per my suggestion create the job to run every 30 day for once and call the proc it should contain update statement like...

update table test set flag=y where falg=n update table test set flag=n where falg=y

Upvotes: 1

Related Questions