January 20, 2009 at 3:27 am
Hi everybody,
i work with sql server 2005 and i must to create a batch with some t sql commands inside and this batch must be execute while the night !
All right, but the problem is i don't know how to create this file !? and how to execute it in the night !?
I'm a beginner, someone can tell me some sample for to begin !?
thanks for your time
christophe
January 20, 2009 at 3:46 am
Hi,
Is there any specific reason that it should be a batch file. A SQL job can also be created with those T-SQL coomands and can be scheduled to run at a specified time. If batch file needs be created, I think, you can use OSQL command to make a connection to the server and then specify the path of the file where the T-SQL commnda are there.
Ex: osql -E -S ";
If log should be generated then
osql -E -S "; You can use other appropriate switches as per your requirement.
Save this file with .bat extension.
This batch file can then be scheduled using windows scheduler task or can be executed from a sql job.
[font="Verdana"]Renuka__[/font]
January 20, 2009 at 5:49 am
Check out the Books Online for the topic SQL Agent. Agent is a scheduling process that will let you run lots of stuff, including TSQL batches, on a scheduled basis. The last poster was referring to Jobs, those are the processes that get scheduled inside Agent.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply