Azure data factory insert script : Must declare the table variable

fry 319 1 Reputation point
2022-04-20T10:39:53.383+00:00

Hello,

I am currently working on a script able to insert one single line of data from collected variables during the pipeline execution.

The problem is i keep running into a "Must declare the table variable "@CONNECTOR_DB"." error and i cant find how to solve it.

The script i'm trying to run is a very simple Insert :

INSERT INTO @CONNECTOR_DB
VALUES(@PIPELINE_ID,@IMPORT_DATE,@NB_ROWS_READ,@NB_ROWS_WRITTEN,@NB_ERROR_ROWS,@COMMENT,@Gaydamak _NAME)

Where @CONNECTOR_DB is @{pipeline().parameters.connectorDb}.T_ImportHistory_IH

194673-image.png

I've tried other ways to enter the connectorDb but i keep running into syntax errors or "unexpected character ." and the likes.

Please advise.

I also want to apologize, english is not my first language.

Have a nice day.

Azure SQL Database
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,160 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Pratik Somaiya 4,206 Reputation points
    2022-04-20T10:54:18.733+00:00

    Hello @fry 319

    Can you store the metadata in a file in data lake and use a Lookup activity and pass the metadata to the foreach activity

    This way you can pass the parameters and execute the pipeline

    Does the connectorDB parameter having any value or is it an empty string?

    1 person found this answer helpful.

  2. AnnuKumari-MSFT 32,011 Reputation points Microsoft Employee
    2022-04-25T18:43:26.25+00:00

    Hi @fry 319 ,

    Welcome to Microsoft Q&A platform and thankyou for posting your query.

    As I understand your query here, you are trying to make use of Script activity by using script parameters but it's failing with the error: "Must declare the table variable ".

    TableName cannot be passed as a parameter.

    The logic behind this is same as how you write the SQL query where you can make use of input and output parameters , however, tableName can't be parameterized.

    196362-image.png

    196373-image.png

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you.
      Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators