Run Query from Task Scheduler

Hi All,

I am using Windows 7 (Task Scheduler), SQL 2008 R2.

I need to schedule a query to run from my desktop using the Task Scheduler.  
Can this be done? If so, how?

Who is Participating?
lcohanConnect With a Mentor Database AnalystCommented:
Basicaly same idea as above and full credits to "sqlservr" just one link to help you with more details:

Lesson 2: Running Transact-SQL Script Files by Using sqlcmd
Ramesh Babu VavillaConnect With a Mentor Commented:
save you query as .sql file.(sql script)
thenn follow this query
sqlcmd -E -S .\SQLEXPRESS -i Sql_Script.sql -o RestoreDB.log

\SQLEXPRESS ----server detials
-i script name
-o result to a file

open the scheduler in windows and create batch file of the script
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.