Link to home
Create AccountLog in
Avatar of Soter13
Soter13

asked on

How do I exec SQL Query from Windows Task Scheduler

I am running an SQL Server Express 2008 on a Windows Server 2008 R2. I want to make a task on Windows Scheduler (express edition doasn't have SQL Agent) which will run an SQL Query every day. The Query just truncates a table and fill it again with refresh data
ASKER CERTIFIED SOLUTION
Avatar of pivar
pivar
Flag of Sweden image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of Soter13
Soter13

ASKER

Thanks Peter, I'm gonna give it a try
Avatar of Éric Moreau
do you know Express Maint? Check it from http://expressmaint.codeplex.com/
Avatar of Soter13

ASKER

It opens a message: "T-SQL execution command line utility has stopped working"
How does your command line and sql script look like?
Avatar of Soter13

ASKER

I tried it in both ways:
sqlcmd -S .\SQLExpress -i c:\Refresh_RepoForBulkMails.sql
sqlcmd -S .\SQLExpress  -U <username> -P <password> -i c:\Refresh_RepoForBulkMails.sql
Avatar of Soter13

ASKER

The original SQL Script is huge, so I use the following for my tests:

USE [Asf_PROD]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

insert into OdikiGR
select 12345,'test','123','123','01-01-2000','01-01-2000','01-01-2000',100.25,150.52,1
I never seen that error message. Googling it, the only solution mentioned is re-installing.

The sql and the 2nd commandline, you need login, looks ok. Have you tried a real simple case, like

sqlcmd -S .\SQLExpress  -U <username> -P <password> -Q "select 'test';"
Avatar of Soter13

ASKER

I tried that, same error message.

I'm not going toy reinstall SQL Server. I have several DBs on it...
I will execute the SP from an ASP page and then schedule IE to call the page