Referencing a column by specifying the schema or the database is deprecated. It is retained temporarily for backward compatibility, but it will
eventually be removed from the language. You should only use one part (column_name
) or two part (table_name.column_name
)
references.
Noncompliant code example
SELECT dbo.table1.col1, -- Noncompliant, three-part column reference
MY_DB.dbo.table1.col2 -- Noncompliant, four-part column reference
FROM MY_DB.dbo.table1;
SELECT dbo.table1.name, -- Noncompliant
dbo.table2.name -- Noncompliant
FROM dbo.table1
JOIN dbo.table2
ON dbo.table2.id = dbo.table1.id; -- Noncompliant
Compliant solution
SELECT col1,
col2
FROM MY_DB.dbo.table1;
SELECT table1.name,
table2.name
FROM dbo.table1
JOIN dbo.table2
ON table2.id = table1.id;