I have this create view script that references INFORMATION_SCHEMA.COLUMNS in two SQL projects.
Both projects have the same target platform "Microsoft Azure SQL Data Warehouse", same compability level "Sql Server 2017 (140)" and otherwise same settings as far as my knowledge of settings stretch.
Both projects are a single solution with a single project.
Using Visual Studio 2022 one project builds just fine, no errors. The other fails and displays SQL71501 errors for unresolved references for a particular script that is part of both projects.
I'd like to find out why the same code builds just fine in one project but fails in the other?
The error message:
Severity Code Description Project File Line Suppression State Error SQL71501: Computed Column: [dv].[vw_GetObjectColumnDefinitions].[SourceObjectName] has an unresolved reference to object [INFORMATION_SCHEMA].[COLUMNS].[TABLE_NAME]. fake-database-name C:\Users\fake\source\repos\fake-solution-name\fake-database-name\dv\Views\vw_GetObjectColumnDefinitions.sql 13
The SQL script:
CREATE VIEW dv.vw_GetObjectColumnDefinitions
AS
SELECT SourceObjectName = TABLE_NAME
, COLUMN_NAME as ColName
, CASE IS_NULLABLE WHEN 'YES' THEN ' NULL ' ELSE ' NOT NULL ' END as ColIsNull
, REPLACE(DATA_TYPE, 'Datetime', 'Datetime2') as ColDataType
, CASE WHEN NULLIF(CHARACTER_MAXIMUM_LENGTH, -1) IS NULL THEN NULL ELSE '(' + CAST(CHARACTER_MAXIMUM_LENGTH as varchar) + ')' END as ColCharLength
, CASE WHEN DATA_TYPE LIKE 'NUM%' OR DATA_TYPE LIKE 'DEC%' THEN '(' + CAST(NUMERIC_PRECISION as varchar) + ', ' + CAST(NUMERIC_SCALE as varchar) + ')' ELSE NULL END as ColNumPrecision
FROM INFORMATION_SCHEMA.COLUMNS