0

I am working on a business application that had been developed using ASP.NET (C#) & SQL Server 2000. I want to develop a mechanism to automatically transfer some data from my SQL Server database to a sybase database after every 5 minutes.

According to my current knowledge, there are two approaches to achieve this.

  1. Use timer to start a thread in my ASP.NET application that reads data from SQL Server & write to Sybase.

  2. Develop a Windows Service that reads data from SQL Server & write to Sybase.

So my questions are:

  1. Which option is best?
  2. What are the pros & cons of each option?
  3. Is there any other approach available to do this data transfer?
3
  • ASP.Net is a very poor choice for scheduled tasks. A SQL Job might be able to do it. Question is too broad for specific answers. Commented Dec 15, 2017 at 18:44
  • If you're manually starting threads in your ASP.NET site, if one of those threads has an unhandled exception, your whole site will crash. ASP.NET is a terrible choice for this sort of thing. Commented Dec 15, 2017 at 19:13
  • How is it possible to transfer data using SQL Agent Job from SQL Server database in Sybase database? Commented Dec 16, 2017 at 6:52

1 Answer 1

1

I would go with a Windows Service for this. ASP.NET will not be a good solution for this kind of task — after all, even when it is not sending the data. Unless you consider the Task API, and asynchronously program the ASP.NET web app to do this, you are going to make mistakes. It is also unsure whether your environment would support all the modern features (such as the Task API or the jobs in the SQL Server with all features and services), which is why a native service would be a perfect way to go.

private async Task saveData() {
    // Copy the data

    // Wait for 5 minutes "asynchronously"
    Task.Delay(5 * 60 * 1000); // 5 minutes
}

Lastly, just iterate over it, while(true) perhaps would do this for you. But, in most cases you will only fire in your own foot.

I would recommend using Windows Service, or any

  • Managed
  • Timer based
  • Asynchronous

... service, that executes a task every n minutes.

Other than that, I would recommend considering the SQL Server itself to do the job for you. Here is another answer that demonstrates how you can do this: Execute stored procedure from a Trigger after a time delay; create the jobs in the SQL Agent Job. https://learn.microsoft.com/en-us/sql/ssms/agent/schedule-a-job

Sign up to request clarification or add additional context in comments.

2 Comments

Thank Afzaal for your response. You mentioned SQL Agent Jobs in your answer. Is it possible to transfer data using SQL Agent Job from a database in SQL SERVER to a database in SYBASE? Both of them are two different Database Management Systems. If I had both of my databases (both source & destination) in same DBMS then I may consider using SQL Agent Job. But can it work for different DBMS? Please explain.
@Somi, no you are right and I only mentioned that for triggers. Anyways, there is another thread that talks about this; dba.stackexchange.com/questions/114634/…, it is the other way around, importing the Sybase database to SQL Server -- you can invert things a bit. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.