How to pass a large number of parameters (say 20+) to stored procedure from code?
Like we can group all the parameters in one class object and then pass it across, but h
If you are using SQL Server 2008, use a table-valued parameter. If you are not familiar, it basically allows you to pass a table as a param to a stored procedure. The benefit is that you can structure the DataTable
you pass in to look however you want.
I did something like this and instead of passing dozens of params, I passed in a single TVP with two columns [KEY] and [VALUE]. That way when your parameters change in the future, there exists a layer of abstraction to insulate the migration. Of course, how you choose to implement it depends on the situation.