DF028: Hardcoded database name is used.
Last modified: December 25, 2024
The topic describes the DF028 T-SQL code analysis rule.
Category
EXECUTION RULES
Message
Hardcoded database name is used.
Description
Do not use hardcoded database names to avoid portability and/or deployment issues.
Additional information
Hardcoded database names make the code less portable. If you need to deploy the same code to multiple environments (e.g., development, testing, production), each with a different database name, you would need to modify the code each time, increasing maintenance overhead.
Additionally, hardcoding database names can potentially expose sensitive information about your database structure, making it easier for attackers to target your system.
Noncompliant code example
SELECT
sale_id
,name_name
FROM shop_db.dbo.sales;
GO
Compliant solution
SELECT
sale_id
,name_name
FROM dbo.sales;
GO
Was this page helpful?