0

I following an SO question on how to truncate a table in Azure SQL DB with ADF how to replace data in azure sql database using azure data factory?

I am trying to emulate the sample in the question using my Copy Activity as follows:

My Source details are as follows:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

With the above configuration I get the following error:

{
    "errorCode": "2200",
    "message": "ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed with the following error: 'Cannot find the object \"targettable\" because it does not exist or you do not have permissions.',Source=,''Type=System.Data.SqlClient.SqlException,Message=Cannot find the object \"targettable\" because it does not exist or you do not have permissions.,Source=.Net SqlClient Data Provider,SqlErrorNumber=4701,Class=16,ErrorCode=-2146232060,State=1,Errors=[{Class=16,Number=4701,State=1,Message=Cannot find the object \"targettable\" because it does not exist or you do not have permissions.,},],'",
    "failureType": "UserError",
    "target": "Copy From CRM to SQLDB",
    "details": []
}

However, if I were to hardcode the schema and table name as follows TRUNCATE TABLE dbo.mytablename everything would work fine.

By way of an update, I just tried with the following parameters

TRUNCATE TableName@pipeline().parameters.TableName

And it failed.

2
  • did you try TRUNCATE table @{pipeline().parameters.TableName}? Commented Feb 26, 2023 at 11:56
  • Hi @RakeshGovindula, I haven't tried that. I will try that right now .. thanks for reaching out. Commented Feb 26, 2023 at 12:06

1 Answer 1

1

Message=A database operation failed with the following error: 'Cannot find the object \"targettable\" because it does not exist or you do not have permissions.

This error occurred because of this query TRUNCATE TABLE dbo.targettable.

  • Here targettable is a SQL database parameter and we cannot access its value inside pipeline and also you have given it with query.
  • It made the meaning of SQL query as to truncate the table named targettable which is not available in the database and that's why it gave you the above error.

To resolve it give the correct parameter in the query with string interpolation like below.

TRUNCATE table @{pipeline().parameters.TableName}

enter image description here

I have given the pipeline parameter as sample1 which is my table name.

Before Truncate:

enter image description here

After Truncate:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.