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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
do you know Express Maint? Check it from http://expressmaint.codeplex.com/
ASKER
It opens a message: "T-SQL execution command line utility has stopped working"
How does your command line and sql script look like?
ASKER
I tried it in both ways:
sqlcmd -S .\SQLExpress -i c:\Refresh_RepoForBulkMail s.sql
sqlcmd -S .\SQLExpress -U <username> -P <password> -i c:\Refresh_RepoForBulkMail s.sql
sqlcmd -S .\SQLExpress -i c:\Refresh_RepoForBulkMail
sqlcmd -S .\SQLExpress -U <username> -P <password> -i c:\Refresh_RepoForBulkMail
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-2 000','01-0 1-2000',10 0.25,150.5 2,1
USE [Asf_PROD]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
insert into OdikiGR
select 12345,'test','123','123','
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';"
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';"
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
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
ASKER