none
Referencing an unexisting column does not make SSDT build fail RRS feed

  • Question

  • Hello,

    Lately, we had an issue that made table columns cleanup more difficult.

    Some remaining column references in stored procedures didn't not make SSDT build to fail. 

    Here is how i reproduced this issue : 

    CREATE TABLE [dbo].[Table1]
    (
    	[Id] INT NOT NULL PRIMARY KEY
    )
    
    CREATE PROCEDURE [dbo].[Procedure1]
    AS
    DECLARE @tv TABLE (id INT PRIMARY KEY)
    
    SELECT t1.Id
    	,t1.DoesNotExists
    FROM dbo.Table1 t1
    INNER JOIN @tv t2 ON t1.Id = t2.id
    
    RETURN 0

    This code builds without any error even if the stored procedure Procedure1 references a column from t1 (t1.DoesNotExist) that doesn't exist.

    This issue only appears when we perform a JOIN on a table variable.

    Used in combination of an EXISTS, the build fails as expected

    CREATE TABLE [dbo].[Table1]
    (
    	[Id] INT NOT NULL PRIMARY KEY
    )
    
    
    CREATE PROCEDURE [dbo].[Procedure1]
    AS
    DECLARE @tv TABLE (id INT PRIMARY KEY)
    
    SELECT t1.Id
    	,t1.DoesNotExists
    FROM dbo.Table1 t1
    WHERE EXISTS (
    		SELECT 1
    		FROM @tv t2
    		WHERE t1.Id = t2.id
    		)
    
    RETURN 0


    Is it an issue you're aware of ? Is there a fix available ?

    My setup is Visual Studio 2017 and SQL Server Data Tools 15.1.61801.210.

    Thanks

    Klébert

    Wednesday, April 4, 2018 8:51 AM

All replies

  • I encounter this problem constantly in the development process. 
    Building takes no garantue that your code is clean. Often we have to see failures only in deployment process. 
    It is very important in dev process to be sure that all your referenced right. If IDE doesnt garantue this and dont helping - why it should be needed?

    Microsoft - please - make your product helpfull And answer please on this important question!
    • Edited by Uniqas Tuesday, November 5, 2019 11:27 AM
    Tuesday, November 5, 2019 9:06 AM