Skip to content

Handle SQL parameter limit in GetTimeValues queries - #239

Merged
JohannesFinsveen merged 2 commits into
masterfrom
fix/more-than-2098-timeperiods
Aug 21, 2026
Merged

Handle SQL parameter limit in GetTimeValues queries#239
JohannesFinsveen merged 2 commits into
masterfrom
fix/more-than-2098-timeperiods

Conversation

@JohannesFinsveen

Copy link
Copy Markdown
Collaborator

Refactored time value retrieval to avoid exceeding SQL Server's 2,100 parameter limit. Added GetTimeValues_outer to split large parameter lists into chunks, query each chunk, and merge results. Renamed original GetTimeValues to GetTimeValues_inner and updated GetTimeValueList to use the new logic. This ensures support for large datasets without hitting SQL parameter constraints.

Both code and text from AI :-)

In ssb the max no. periods is less than 1400.

Refactored time value retrieval to avoid exceeding SQL Server's 2,100 parameter limit. Added GetTimeValues_outer to split large parameter lists into chunks, query each chunk, and merge results. Renamed original GetTimeValues to GetTimeValues_inner and updated GetTimeValueList to use the new logic. This ensures support for large datasets without hitting SQL parameter constraints.

@runejo runejo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but could you also fix the two SonarCloud issues?

@JohannesFinsveen

Copy link
Copy Markdown
Collaborator Author

The two sonarCloud issues are now accepted.

}

private DataSet GetTimeValues(string aMainTable, ICollection<string> valuesFromPxs)
private DataSet GetTimeValues_outer(string aMainTable, ICollection<string> valuesFromPxs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe keep the method name GetTimeValues instead of GetTimeValues_outer, otherwise it LGTM 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

@likp

likp commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

@JohannesFinsveen I have tested it with one of our tables that was failing and now it works. Change back the name of the method see @runejo comment above and I am ready to approve the change.

@sonarqubecloud

Copy link
Copy Markdown

@JohannesFinsveen
JohannesFinsveen merged commit 4433dbb into master Aug 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can not donwload more than 2098 timeperiods

3 participants