Can you please help me how to execute a stored procedure automatically in SQL database without any transaction in SQL? I want to execute on particular fix time.
-
1What database system are you using? SQL Server (Microsoft), MySQL, other? Please edit your question to add a tag for that. Also, what have you tried so far, what did you find in your research and why didn't that work?– MatCommented Sep 20, 2013 at 5:52
-
It's a stored procedure - a procedure stored inside your database system. It has nothing to do with a "store" per se ...– marc_sCommented Sep 20, 2013 at 8:31
-
how about this? stackoverflow.com/a/8688446/2186023 and then just let task scheduler take control of that...– DrCopyPasteCommented Sep 20, 2013 at 8:45
-
2And you can not execute anything in SQL without a transaction. ANYTHING is in a transaction - explicit or implicit.– TomTomCommented Sep 20, 2013 at 9:13
-
Cross-site duplicate of stackoverflow.com/q/4079363/164901 -- I recently implemented the Service Broker solution for one of our projects here, and I can tell you that it's not exactly newbie-friendly. It is a great solution, though.– Jon SeigelCommented Sep 20, 2013 at 13:31
4 Answers
If you are not comfortable using Powershell, then you can go for native service broker functionality.
This might sound complex, but below links has all the scripts :
Alternatively, you can use Standalone SQL Agent - still in BETA statge from codeplex.
You can use the native sqlcmd functionality and then schedule it using windows scheduler or Schtasks
sqlcmd -E -S server_name -d database_name -Q "EXEC schema_name.StoredProcedureName @p1"
With SQL Server Express, you could use powershell to execute a stored procedure automatically through Windows scheduler service.
There is a great article that shows how to use Powershell to EXEC stored procedures here:
http://www.maxtblog.com/2010/10/basic-sql-server-stored-procedure-scripting-with-powershell/
You can also look at this question that deals with using Powershell:
Is there any collection of PowerShell scripts that help the task of SQL Server maintenance?
Not sure what you mean by "without any transaction". But normally timed scripts / tasks are executed as jobs, through the SQL Server Agent. See here for an example and explanation.
https://stackoverflow.com/questions/1216272/how-to-execute-a-stored-procedure-in-a-sql-agent-job
The answer to the question "How to make a stored procedure automatic with execution parameters" in Sql server is simple, we will only have to go to the SQL server Agent, "New" -> "Job" -> we will use three tabs "General"," Steps","Schedules" in "General" we will only give it a name, "Steps" ->"New" and here we will have to add the execute of the stored procedure, "Schedules" we make the execution time parameters and save, I hope this is of help to someone, greetings
-
1The question is tagged "SQL Express" which does not have SQL Agent as an option. Commented Jun 28, 2023 at 15:30
-
1
-
La pregunta esta etiquetada como "Como ejecutar automáticamente un procedimiento almacenado" por eso específico para aquellos que buscan una solución en SQL server --Saludos Commented Jun 28, 2023 at 21:18