title: Conversion failed when converting datetime from character string in store procedure
body: <p>I am getting conversion error when running the below sql in store procedure becasue of some reason I can't cast into varchar</p>
  
  <pre><code>Declare @sql varchar(100)
  Declare @ddtime datetime
  
  set @ddtime = '2012-02-03 22:14:50.057'
  
  set @sql = 'select * from table1 where tdate='+@ddtime
  
  exec(@sql)
  </code></pre>