title: How to extract text between square brackets in TSQL
body: <p>I have the following query:</p>
  
  <pre><code>DECLARE @value as nvarchar(max)
  SET @value   = '(company.[department] LIKE ''Development'')';
  </code></pre>
  
  <p>I would like to extract the word between brackets keep it in a value and then put as input in a replace function like this.</p>
  
  <pre><code>select replace(@value, @department, 'another_string');
  </code></pre>
  
  <p>You will say probably why I don't do it immediately with the replace function.
  The case is that this department string may change dynamically to another string for example country and I would like every time to keep this choice and change it with a value.</p>