title: Use default value of a column in stored procedures
body: <p>I am using SQL Server 2012 and I have 2 tables with the following definition</p>
  
  <pre><code>CREATE TABLE t1 (id INT PRIMARY KEY, value NVARCHAR(10))
  CREATE TABLE t2 (id INT PRIMARY KEY, value BIT DEFAULT 1)
  
  ALTER TABLE t2 WITH CHECK ADD CONSTRAINT FK FOREIGN KEY(id) REFERENCES t1 (id)
  </code></pre>
  
  <p>I inserted the following columns for the current example:</p>
  
  <pre><code>INSERT INTO t1 VALUES (1, 'a')
  INSERT INTO t1 VALUES (2, 'b')
  INSERT INTO t1 VALUES (3, 'c')
  
  INSERT INTO t2 VALUES (1, 1)
  INSERT INTO t2 VALUES (3, 0)
  </code></pre>
  
  <p>I am running this query and it works</p>
  
  <pre><code>SELECT
    t1.*, ISNULL(t2.value, 1)
  FROM
    t1
    LEFT JOIN t2 ON t1.id = t2.id
  </code></pre>
  
  <p>Is there any way to replace the <code>1</code> in this part <code>ISNULL(t2.value, 1)</code> with the default value that I have defined in the column <code>value</code> in the table <code>t2</code>?</p>
  
  <p>Here is the sqlfiddle I created with this example: <kbd><a href="http://sqlfiddle.com/#!6/e41b0e/1" rel="nofollow noreferrer"><code>SQLFIDDLE DEMO</code></a></kbd></p>
  
  <p><strong>UPDATE 1:</strong><br>
  I can't use <a href="https://stackoverflow.com/questions/3817885/sql-server-find-out-default-value-of-a-column-with-a-query">SQL Server: Find out default value of a column with a query</a> because it returns <code>((1))</code> and I can't cast <code>((1))</code> to <code>BIT</code>.
  Is there any way to fix that?</p>