How to add many Parameters to ExecuteNonQuery, for IN() function in Sql?

I add ExecuteNonQuery activity as picture below.

I set Sql as code and picture below.

UPDATE [dbo].[Calendar] SET [Active] = 0 WHERE [CalendarID] IN (@CalendarID)

First scenario, I have one CalendarID and set Parameters as picture below. It’s work, updated column in database.

Second scenario, I have two CalendarID and set Parameters as picture below. It’s not work.

Could someone please help to suggest me?

1 Like

Try with the following value,
"'value1','value2'"

@KarthikByggari, I had tried for both picture below. It’s still not work for both.

Here IN is an operator. So it expects a set of values but not string value.
That’s why it is failing. There are alternative ways how to pass the list of values as a parameter.
Please check the below links for an idea.

http://www.sommarskog.se/arrays-in-sql.html

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/f8cf78f5-f35c-47cd-9de9-63400565fd50/use-multiple-values-from-parameters-in-tsql-query?forum=transactsql

Regards,
Karthik Byggari

1 Like

@KarthikByggari, Thank you very much for the concept.

1 Like

Can you tell me, how to use the in arguments inside the query???..
@akkapolk

Hi @akkapolk,

Here is the sample project for passing parameter to the ExecuteNonQuery…

Regards
Balamurugan.S

1 Like