title: Error converting data type varchar to date in SQL Server 2008 R2
body: <p>I have the date to check as shown below:</p>
  
  <p>Input Date:</p>
  
  <pre><code> 17-09-2014
  </code></pre>
  
  <p>For which I am converting in my dynamic script:</p>
  
  <p>Attempt #1:</p>
  
  <pre><code> CAST((convert(date,@FDate, 105)) AS nvarchar(50))
  </code></pre>
  
  <p>Error: </p>
  
  <blockquote>
    <p>Error converting data type varchar to date.</p>
  </blockquote>
  
  <p>Attempt #2:</p>
  
  <pre><code> convert(date, @FDate, 105)
  </code></pre>
  
  <p>Error: </p>
  
  <blockquote>
    <p>The data types nvarchar and date are incompatible in the add operator.</p>
  </blockquote>
  
  <p>Attempt #3:</p>
  
  <pre><code> cast(@FDate as varchar(50))
  </code></pre>
  
  <p>Error: </p>
  
  <blockquote>
    <p>Error converting data type varchar to date.</p>
  </blockquote>
  
  <p>One whole attempt, taken from the sqlfiddle.com/#!3/d41d8/38976 of the comments:</p>
  
  <pre><code>DECLARE @querys NVARCHAR(max)
  DECLARE @Date DATE
  SET @Date = '17-09-2014'
  
  SET @querys = 'SELECT' + CAST((convert(date,@Date, 105)) AS nvarchar(50)) + ''
  EXEC(@querys)
  </code></pre>