Wits end with MSSQL Automation issue - object reference not set to an instance of an object

Hi there.

I am hitting my head against the wall trying to solve this mystery.

I have a Windows 10 server that houses all my automated jobs. I need to ensure they all run when the server is not up. I have no problem with jobs created from any databases in the company (we have them all ;)) but MSSQL. And there is the problem. When I create an automated job with a simplest query "Select * from client" with file attached and email, I have no problem this job to be processed - file created, email with attachment sent.

then comes big HOWEVER. When I replace the script with more complicated one or create a new job - file create and email sent - I get an error message "object reference not set to an instance of an object ". The file is getting created. But it can't attach itself to the email.

I cannot understand why this is happening when I "drop" more complicated query in the same .tas as simple one that worked.

Any assistance is greatly appreciated. I have to make this work as this server is getting updates without my knowledge and I need to ensure that jobs run when it is not logged it.

thank you all! Stay safe!

How many attachments are you sending with the email? If it is only one make sure nothing else is overwriting/deleting it (the variable that is not the actual file). Make sure the variable that points to the file location is in scope with the email process. If the variable is local (declared or initialized inside a loop or container) the mail step needs to be inside also or make sure you use the right set variable to set the value inside that gets used outside. There are two set variables one initializes and sets the other just sets. If you initialize outside and then again inside you get two variables with the same name but one is local and does not touch the other one. To set the just the value inside for an outside variable use the other one.

Thank you for your reply. I didn't see it until now. I actually had to set up a help ticket with Quest and they have assisted.