title: Using name of a database inside a sql script for a full table name
body: <p>I struggled for a while with a bug, and then found out the reason for it in a database stored procedure code, which contained the old name of a database in a table name, whereas the current database name was already different. So, I'd like to ask:<br></p>
  
  <p><strong>Is there a situation in which using a database name as a part of a full table name (<em>database name + schema name + table name</em>) can be justified (provided we don't touch tables in other databases) or is it always a bad practice?</strong> How to correctly use a database name in sql scripts to keep code neutral to a specific database?</p>
  
  <p>Code just for an illustration:</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[MyProc] 
  AS
  BEGIN
   DELETE FROM [MyDatabase].[dbo].[MyTable] 
  END
  </code></pre>