title: dynamic sql database name replace
body: <p>I have a requirement where I have to replace the database names in the dynamic sql with the new database names . </p>
  
  <p>something like following:</p>
  
  <p><code>select * from DBName.TableName</code> </p>
  
  <p>should become</p>
  
  <pre><code>select * from newDBName.TableName 
  </code></pre>
  
  <hr>
  
  <p><code>select * from [DbName].TableName</code></p>
  
  <p>should become</p>
  
  <pre><code>select * from [NewDbName].TableName
  </code></pre>
  
  <p>I have tried <code>string.Replace()</code> method but that doesn't respect all combinations a programmer can write the database names in a dynamic sql</p>
  
  <p>Please help.</p>