Solved

Run Query from Task Scheduler

Posted on 2011-09-22
2
400 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
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…

760 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

23 Experts available now in Live!

Get 1:1 Help Now