I need some help with this.
I've scheduled a task on Windows Task Scheduler, that calls the command OSQL using the parameter: -i "ScriptPath"
That is OSQL command executes the script stored in the path.
My problem is this:
- My script starts doing a USE [DatabaseX]
- DatabseX does not exist on the server, so the script fails.
- But the Scheduled Task ends with a Successful result 0x0, even if the script fails.
If the script fails, I need to see that the last run failed in the scheduled task.
Is this possible? Could somebody help me with this?
EDIT: Changed OSQL to SQLCMD, but the problem is the same. The Scheduled Task result is OK even if the script fails.
Thanks & Regards,