Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 910669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:04:50+00:00 2026-05-15T17:04:50+00:00

Task: Write timestamps into MS SQL database table every second. Solutions: External application which

  • 0

Task:

Write timestamps into MS SQL database table every second.

Solutions:

  1. External application which writes timestamps by schedule (Sql agent for example).
  2. Stored procedure, which writes timestamps in infinite loop.

Questions.

  1. Which of the solutions is best?
  2. Is there any drawbacks of running infinite loop in stored procedure?
  3. How to start stored procedure after server reboot?
  4. Any other solutions?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:04:51+00:00Added an answer on May 15, 2026 at 5:04 pm

    1, Both have advantages and disadvantages. Evaluate and choose based on your environment

    Procedure Advantages:
    – Don’t have overhead of SQL Agent processing once per second. (In fact, I don’t think you can get SQL Agent to consistantly launch the same job once per second.)
    – I don’t think a procedure in WAITFOR mode is using resources – but you’d want to check

    Procedure Disads:
    – If procedure fails (gets stopped somehow), it won’t start up. (Unless you have a SQL Agent job running to check if the procedure has stopped, in which case might as well go with the procedure)
    – Might be easier to stop/break than you’d think (concurrency/deadlocks, detached DBs, manually stop during maintenance then forget to restart)

    Job Advantages:
    – If job fails (perhaps db is unavailable), next job will still get launched

    Job Disads:
    – Seems very kludgy, having SQL agent run every second. Measure required server overhead if you do this.
    – If SQL Agent fails or is stopped, job won’t run

    A suggestion: must it be once per second? Can it be once per 5, 10, 15, or 30?

    2, Shouldn’t be any, barring what’s mentioned above. Make darn sure you can’t hit locking, blocking, or deadlock situations!

    3, Like @gbn says, sp_procoption

    4, Nothing that doesn’t involve cumbersome tricks based on pessimistic locking techniques, or byzantine logic based on the timestamp (not datetime) datatype. The best fix would seem to be the long-term one of combining those two databases into one, but that’s not a short-term option.

    Out of sheer paranoia, I’d combine the two like so:

    • Job set to run every 2, 3, or 5 minutes
    • Job calls procedure that updates your timesampt, then waitfors a few seconds
    • Procedure does not stop, so job continues to run; while job is running, it will not be started (because it’s still executing)
    • If procedure somehow dies, job will launch it again next time it’s scheduled to run.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My task is to write an app(unfortunatly on C) which reads expression in infix
My task is to write a class RFind which recursively searches the current directory
The task is to write a program which prompts for a filename and then
I have task to write program allowing users to draw stars, which can differ
I have inherited some code which involves a scheduled task that writes data (obtained
Here's the deal. The task is to write a function which should be able
I have a task to write a set of http unit tests, which should
Ive got task to write code to export html table with headers to excel.
I have an interesting task: to write a program which captures input from the
I have a task to write a program which handles the division by zero

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.