SA0253 : The current database is hardcoded in object reference

The topic describes the SA0253 analysis rule.


The current database is hardcoded in object reference


The rule looks inside SELECT, UPDATE, DELETE, INSERT, MERGE and EXECUTE statements for object qualified with current database.

Do not use three and four part identifier names with hardcoded references to the current database.

This way using hardcoded current database name, could later cause maintainability problems as for example if the code is used in another database or the database name is changed.

How to fix

Rewrite the identifier name and remove the database identifier part, which is the hardcoded current database name.


The rule has a Batch scope and is applied only on the SQL script.


Rule has no parameters.


The rule requires Analysis Context. If context is missing, the rule will be skipped during analysis.

Effort To Fix
8 minutes per issue.

Design Rules, Bugs

Additional Information

There is no additional info for this rule.

Example Test SQL
1EXECUTE database1.schema1.proc1
2EXECUTE adventureWorks2008r2_test.schema1.proc1

Example Test SQL with Automatic Fix
1EXECUTE database1.schema1.proc1
2EXECUTE schema1.proc1schema1.proc1

Analysis Results
  Message Line Column
1 SA0253 : The current database is hardcoded in object reference. 2 8
See Also

Other Resources