Execute Query cannot exceed more than 16 arguments

Hi,

I’m trying to pass 17 parameters to the Store Procedure but i’m getting the following error:

image

My query is as such:

“EXEC AutoMatch.sp_batchInsert @param1 = '”+param1+“', @param12= '”+param2+“', @param3= '”+param13+
“', @param4= '”+param4+“', @param5= '”+param5+“', @param6= '”+param6+“', @param7= '”+param7+
“', @param8= '”+param8+“', @param9= '”+param9+“', @param10= '”+param10+“', @param11= '”+param11+
“', @param12= '”+param12+“', @param13= '”+param13+“', @param14= '”+param14+“', @param15= '”+param15+
“', @param16= '”+param16+“', @param17= '”+param17+“'”

@jordan.c

Instead of passing as parameters try to add the extra ones as variables directly in the statement…or add all as variables both should work

Cheers

Hi @Anil_G,

I did pass them as variables if you look at the statement I pasted. If I removed the EndDate variable then it will work otherwise it will generate the said error message.

@jordan.c

One work around int hat case would be …if there are any string parameters combine them with delimitter and then inside the storedproc split and use it

Cheers

1 Like

In case this helps others as well, I’ve used the following formula as per your guide:

combineDates = String.Join(“-”, startDate, endDate)

Then within the SQL Query, i use:
combineDates.Split(“-”)(0) for the first string
combineDates.Split(“-”)(1) for the second string

Thanks @Anil_G, much appreciated.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.