Hi, when i try to execute this sql statement i am getting the error.. Conversion failed when converting character string to smalldatetime data type.
Does anyone know what i am doing wrong?
declare @modality varchar(50)
declare @datefrom smalldatetime
set @modality = 'xxxxxxx'
set @datefrom = '20090101'
declare @var1 nvarchar(4000)
select @var1 =
'select
sum('+ @modality +') as ' + dbo.fnc_titlecase(@modality) +'
from dbo.vw_RawData
where vw.date >= ' + @datefrom + ''
exec sp_executesql @var1