?
Solved

Run Query from Task Scheduler

Posted on 2011-09-22
2
Medium Priority
?
417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Assisted Solution

by:Ramesh Babu Vavilla
Ramesh Babu Vavilla earned 1000 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 40

Accepted Solution

by:
lcohan earned 1000 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

Four New Appliances. Same Industry-leading Speeds.

But don't take it from us.  The Firebox M370 is Miercom tested and Miercom approved, outperforming its competitors for stateless and stateful traffic throughput scenarios.  Learn more about the M370, M470, M570 and M670 and find the right solution for your organization today!

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
Suggested Courses

765 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