I am trying to figure out why Visual Studio does not report error SQL71501 (unresolved reference to an object) when joining temporary table.
I am using VS 2019 version 16.3.6 and the issue can be reproduced by creating a new SQL Server Database Project, adding a new table and stored procedures:
CREATE TABLE [dbo].[Table1]
(
[Id] INT NOT NULL PRIMARY KEY
)
CREATE PROCEDURE [dbo].[Procedure1]
AS
SELECT t1.[Id2] -- Causes error
FROM [dbo].[Table1] t1
RETURN
CREATE PROCEDURE [dbo].[Procedure2]
AS
CREATE TABLE #test ([Id] int)
SELECT t1.[Id2] -- No error and project builds
FROM [dbo].[Table1] t1
JOIN #test t2 on t1.[Id]=t2.[Id]
RETURN
We need to refactor a large database and this hides a lot of errors that should occur when deleting/renaming a database object. Is there a way to fix this?