Forum Discussion
MattSontum
Sep 19, 2025Copper Contributor
Bug: "Invalid column name" after sp_recompile for valid column in custom data type
Hello, I was hoping to find a workaround for an issue I am having. I believe this is a bug in SQL Server (we are using SQL Server 2022) I have written a utility stored procedure for solving the gaps...
martin_smith
Sep 20, 2025Copper Contributor
Has anyone ever seen anything like this?
Yes. I've seen this sort of thing when there are #temp tables named the same in both parent and child scopes.
See this example DB Fiddle https://dbfiddle.uk/H05-MO65
Line numbers often just point to the statement that has the problem rather than the actual specific line so per the additional code you showed in the https://stackoverflow.com/q/79769659/73226 this statement is, in fact, a couple of CTEs followed by
INSERT INTO #Islands (KEY_1, KEY_2, KEY_3, START_DATE, END_DATE)
So you could definitely see this type of thing if the outer proc also has a temp table called #Islands but without the KEY_3 column