Solved

Run Query from Task Scheduler

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

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
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…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

730 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