I am creating a dynamic query in sql server 2005 stored procedure and I am getting error if dates are sent empty/null to the stored procedure that:
This input parameter cannot be converted
So, how to check in Stored procedure that covert only id date is not empty: below is my query. I have checked the null in if condition but then also it is showing me error
If @startDate IS NOT NULL AND @endDate is Not null
Begin
set @strCondition = ' FO.Rf_Date >= convert(datetime, ''' + Convert(varchar,@startDate,112) + ''') and FO.Rf_Date<= convert(datetime, ''' + Convert(varchar,@endDate,112) + ''')'
End