Fix: error while inserting #tuning_recommendations#771
Merged
erikdarlingdata merged 1 commit intoerikdarlingdata:devfrom Apr 28, 2026
Merged
Fix: error while inserting #tuning_recommendations#771erikdarlingdata merged 1 commit intoerikdarlingdata:devfrom
erikdarlingdata merged 1 commit intoerikdarlingdata:devfrom
Conversation
Add TRY_CAST as bigint to avoid conversion failure after parsing the JSON from the sys.dm_db_tuning_recommendations
erikdarlingdata
approved these changes
Apr 28, 2026
Owner
erikdarlingdata
left a comment
There was a problem hiding this comment.
Thanks Claudio — verified locally that the WHERE-clause TRY_CAST resolves the conversion error path. Approving and merging.
This was referenced Apr 28, 2026
erikdarlingdata
added a commit
that referenced
this pull request
Apr 29, 2026
The string-split path that parses sys.dm_db_tuning_recommendations.details returns regressed_plan_id / recommended_plan_id with a leading space because the upstream REPLACE chain inserts ': ' after every colon. The implicit cast on insert into #tuning_recommendations was silently swallowing the space; #771 added a TRY_CAST in the WHERE clause to survive the same surface. Move the type intent to the projection: TRY_CAST(LTRIM(SUBSTRING(...)) AS bigint) so the columns leave the derived table already typed. Drops the redundant TRY_CAST from the WHERE clause. Doesn't touch the splitting math.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #767
Add TRY_CAST as bigint to avoid conversion failure after parsing the JSON from the sys.dm_db_tuning_recommendations