We help IT Professionals succeed at work.
Get Started

SQL Server 2008 Job Fails but runs fine when package executed manually

669 Views
Last Modified: 2016-02-10
Hi all.

I have a SSIS that has a vb script with the code below, it deletes and imports data into a linked server (the linked server is SQL Server 2000):

Dim con As New SqlConnection
        Dim cmd As New SqlCommand
        
        con.ConnectionString = "Data Source=myserver;Initial Catalog=Product;Integrated Security=True"

        con.Open()

        cmd.Connection = con
        cmd.CommandText = "DELETE FROM [mylinkedserver].[mydatabase].dbo.BlanketOrder_ROP"
        cmd.ExecuteNonQuery()

        cmd.CommandText = "INSERT INTO [mylinkedserver].[mydatabase].dbo.BlanketOrder_ROP(ItemNumber, ROP) SELECT ItemNumber, ROP FROM BlanketOrder_ROP"
        cmd.ExecuteNonQuery()

		Dts.TaskResult = ScriptResults.Success

Open in new window


When I execute the package in SQL Server Business Intelligence Development Studio it runs fine with no errors (it actually deletes the data and then inserts the updated data). But when I create a SQL Server Agent Job it fails with the following error:

Source: Import into mydatabase database on mylinkedServer BlanketOrder_ROP table      Description: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: DELETE permission denied on object 'BlanketOrder_ROP', database 'mydatabase', owner 'dbo'

What do I need to do to have the SSIS run through the SQL Server Agent Jobs?
Comment
Watch Question
Senior Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE