Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Nejib
Frequent Visitor

Error in Script Activity with Script parameters

Hi, 

 

I want to use parameters in a script activity. However I get an error trying to do that.

But according to the docuentation, this approach is supposed to work fine (https://learn.microsoft.com/en-us/azure/postgresql/configure-maintain/how-to-data-factory-script-act...).

Do you have an idea of the issue in my example ? 

 

Nejib_0-1770069529584.png

 

 

Nejib_1-1770069666987.png

 

1 ACCEPTED SOLUTION
Shreya_Barhate
Resolver I
Resolver I

Hi Nejib,
You’re running into this because Script activity parameters can replace only values in a SQL/PGSQL statement, not identifiers (like schema, table, or column names). In other words:

Works: using a parameter in predicates or values (e.g., WHERE status = @status).
Fails: trying to use a parameter where SQL expects an identifier (e.g., SELECT @col FROM ... or FROM @schema.@table). In those cases, the engine won’t substitute an identifier. 

If your screenshots show @param inside the SELECT list or the FROM clause, that’s why it errors.
Option1:
If you want to use parameters in sql statement like select,drop,etc
use pipeline parameters 

Option 2:

If you want to use script parameters, you need to create SP
example:
create stored procedure

CREATE OR ALTER PROCEDURE dbo.usp_select_from_any
    @schema_name sysname, @table_name sysname
AS
BEGIN
  DECLARE @sql nvarchar(max) =
    N'SELECT * FROM ' + QUOTENAME(@schema_name) + N'.' + QUOTENAME(@table_name) + ';';
  EXEC (@sql);
END;

call it in script like:

EXEC dbo.usp_select_from_any
     @schema_name = @schema_name,
     @table_name  = @table_name;

Shreya_Barhate_1-1770137377421.png

 



Thanks and Regards,
Shreya

 

View solution in original post

3 REPLIES 3
Shreya_Barhate
Resolver I
Resolver I

Hi Nejib,
You’re running into this because Script activity parameters can replace only values in a SQL/PGSQL statement, not identifiers (like schema, table, or column names). In other words:

Works: using a parameter in predicates or values (e.g., WHERE status = @status).
Fails: trying to use a parameter where SQL expects an identifier (e.g., SELECT @col FROM ... or FROM @schema.@table). In those cases, the engine won’t substitute an identifier. 

If your screenshots show @param inside the SELECT list or the FROM clause, that’s why it errors.
Option1:
If you want to use parameters in sql statement like select,drop,etc
use pipeline parameters 

Option 2:

If you want to use script parameters, you need to create SP
example:
create stored procedure

CREATE OR ALTER PROCEDURE dbo.usp_select_from_any
    @schema_name sysname, @table_name sysname
AS
BEGIN
  DECLARE @sql nvarchar(max) =
    N'SELECT * FROM ' + QUOTENAME(@schema_name) + N'.' + QUOTENAME(@table_name) + ';';
  EXEC (@sql);
END;

call it in script like:

EXEC dbo.usp_select_from_any
     @schema_name = @schema_name,
     @table_name  = @table_name;

Shreya_Barhate_1-1770137377421.png

 



Thanks and Regards,
Shreya

 

tayloramy
Super User
Super User

Hi @Nejib

 

You can use dynamic expressions instead, open the expression builder and build out your query in there. 

The post that @v-menakakota linked has an example of this as the accepted solution. 

tayloramy_0-1770129487126.png

 

 

 





If you found this helpful, consider giving some Kudos.
If I answered your question or solved your problem, mark this post as the solution!

Proud to be a Super User!





v-menakakota
Community Support
Community Support

Hi @Nejib ,

Thanks for reaching out to the Microsoft fabric community forum. 

In Script activities, parameters can be used only for passing values to a query. They cannot be used for SQL object names such as schema or table names. Because of this, using parameters directly in DDL statements like creating or dropping tables results in a syntax error.

 

Please go through the below solved issue, which explains how to construct the SQL statement dynamically using the expression builder, so that the schema and table names are resolved before the script runs.

Solved: Use Script parameters in Script activitie in Data ... - Microsoft Fabric Community

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know. 

Best Regards, 
Community Support Team

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Free Fabric Certifications

Free Fabric Certifications

Get Fabric certified for free! Don't miss your chance.

January Fabric Update Carousel

Fabric Monthly Update - January 2026

Check out the January 2026 Fabric update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.