Why am I getting the following when running the query below?
Msg 241, Level 16, State 1, Line 1
Conversion failed when converting datetime from character string.
What is a character?
select top 1 cast(cast(run_date as varchar)as datetime) as run_date into #0 from msdb.dbo.sysjobhistory
select run_date from #0
--2011-09-08 00:00:00.000
if(select run_date from #0) = datename(wk, getdate())
begin
print
'okay'
end