Skip to content Skip to sidebar Skip to footer

Translate My Code To A Batch File For Me

I need to write a batch file which run automatically at particular time of day and i got many solutions from forums which are working fine but in my case i need to write SQL query

Solution 1:

The simplest solution, since you already have working C# code, is to create a Console Application, and use your existing code in the Main() method.

Compile it into an EXE, and place the EXE somewhere on the computer where the code must run.

Use Windows Task Scheduler to schedule your EXE to run as needed.

Make sure you add logging so you can keep track of any errors that happen when the program runs unattended. NLog is a good place to start.

Solution 2:

If you need to run an application at a specific time each day, and you are using a Microsoft OS, look into the Windows Task Scheduler. You can set a schedule and an action. The action will be to execute your program.

Solution 3:

Look into sqlcmd.exe

Example in bacth:

sqlcmd -Q "EXEC dbo.your_sp" -S server -d db -o C:\output.txt

see Create a Stored Procedure

Post a Comment for "Translate My Code To A Batch File For Me"