Solved

Run Query from Task Scheduler

Posted on 2011-09-22
2
404 Views
Last Modified: 2012-05-12
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?

Thanks,
MTD
0
Comment
Question by:MoreThanDoubled
2 Comments
 
LVL 10

Assisted Solution

by:sqlservr
sqlservr earned 250 total points
ID: 36580291
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
0
 
LVL 39

Accepted Solution

by:
lcohan earned 250 total points
ID: 36581373
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
http://msdn.microsoft.com/en-us/library/ms170572.aspx
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now