Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 It there a way to fun tsql from windows patch file

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2008-09-09 : 13:13:31
I have tsql program, I want to run it automtically at certain time. Can someone point me a way to do that?
Thanks.
Jeff

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-09-09 : 13:28:43
"tsql program"? Do you mean file that contains t-sql statements?
Create a sql JOB, add a job-step which runs your statements, schedule the job to run when you want.

Be One with the Optimizer
TG
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-09 : 13:28:51
Create a job.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

jeff06
Posting Yak Master

166 Posts

Posted - 2008-09-10 : 09:44:56
Thanks for response!
Can you give some instructions on how to create a job?
Thanks.
Jeff
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-10 : 09:53:01
Yes. Open Books Online and follow the instructions about How to create a Job.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

jeff06
Posting Yak Master

166 Posts

Posted - 2008-09-10 : 14:36:42
I have a sql code file stored a file in local directory . Is there a way to run the this sql code file from command line?
Thanks.
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-09-10 : 14:46:02
Yes, using OSQL. Again, Books Online has information about this.

also (from cmd):
OSQL /?

Be One with the Optimizer
TG
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-09-10 : 14:46:05
Yes, you can use sqlcmd. You can even call sqlcmd from a job or you could simply copy/paste the code from the file into tsql job step.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -