Azure data factory insert script : Must declare the table variable

fry 319 1 Reputation point


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 :


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


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

    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

    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.



    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