How do I create a stored procedure?

I have a stored procedure that will fetch a record by todays date when the status is equal to '3'. My problem is I would like the procedure to run as a job every 5 minutes but I only want it to get the record one time. I cannot add another field to the database to track this. What is the simplest way to one record that is equal to todays date and status 3 and when it runs again it will not fectch the same record?

Any help is appreciated
tupac1979Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chapmandewCommented:
You'll have to track it somehow, either through the use of keeping track of the last id returned, or through a table of IDs that you have already returned.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
indianguru2Commented:
Create a Temp table for checking the last value retrieved.
0
chapmandewCommented:
but you'll have to keep track of the last value returned...and the temp table will go out of scope as soon as the proc is returned.
0
experteezCommented:
I don't know what you do with that record, but if you put some data somewhere as soon as you have that record the first time, you could do something like this:

IF NOT EXISTS (SELECT * FROM tblResult WHERE column1 = 'abcde')
         << Do trick here >>

This solves your kind of problems for me in most scenario's...
0
rajesh_chdCommented:
you have to create a dummy table for the fetched records.  When your procedure fetch a record, maintain a copy in this dummy table with the unique id of fetched record.  Next time when procedure fetches records, check the dummy table for existing records and ignore the matches.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.