From: bob123 on
Hi,

I am a beginer in SQL Server

I try to execute a job (maintenance plan)
from osql

I generated the script in a file (backup.sql)

EXEC msdb.dbo.sp_attach_schedule
@job_id=N'1a1e9373-eabf-480d-9b21-ad94025cd230',@schedule_id=21
GO

osql -E -i backup.sql
C:\Temp>osql -E -i backup.sql
1> 2> 1>

and no backup
what I missed ?
Thanks in advance


From: John Bell on
On Sat, 12 Jun 2010 15:28:49 +0200, "bob123" <bob123(a)gmail.com> wrote:

>Hi,
>
>I am a beginer in SQL Server
>
>I try to execute a job (maintenance plan)
>from osql
>
>I generated the script in a file (backup.sql)
>
>EXEC msdb.dbo.sp_attach_schedule
>@job_id=N'1a1e9373-eabf-480d-9b21-ad94025cd230',@schedule_id=21
>GO
>
>osql -E -i backup.sql
>C:\Temp>osql -E -i backup.sql
>1> 2> 1>
>
>and no backup
>what I missed ?
>Thanks in advance
>

Hi

What you are doing is attaching a schedule to the job, not actually
executing it. Use sp_start_job to run the job e.g.

EXEC msdb.dbo.sp_start_job
@job_id=N'1a1e9373-eabf-480d-9b21-ad94025cd230'

John