I have a TVP
myTVP implemented as
select val.* from vw_MyView val. The other day, I modified
select Foo,Bar from DB with
select Foo, Bash, Bar from DB.
This had a strange side effect: Calling
select Bar from myTVP() returned a column named
Bar populated with the contents of
Bash (despite the fact that
Bash don't even have the same type).
Anonymized plan demonstrating the problem: https://www.brentozar.com/pastetheplan/?id=ryJLJmqdl
Object1 are identical, but the output list of the left-most Nested Loop is completely different between the two plans.
- There are no plan hints in use. No trace flags are set.
- CheckDB found no errors.
- Using option(recompile) did not fix the issue.
- Running right-click alter on the TVP with no changes fixed the issue.
- Running right-click alter on the TVP with a name change fixed the issue, but the new TVP was identical to the previous other than the name.
- Using SQL 2014 Standard Edition.
- Is it normal for adding a new column to a view to change which column of the view is used in by other references to that view?
- Under what circumstances will adding a column to a view cause such behavior?