I am attempting to write a fairly simple stored procedure but getting an error when I print @sql
set @where = ' where deliverydate between '''+ @FromDate + ''' and ''' + @ThruDate + ''''
set @where = @where + ' and custlocation = '+ @custlocationID + ''''
The error reads:
Conversion failed when converting the nvarchar value ' where deliverydate between '8/1/2013' and '8/20/2014' and custlocationID = ' to data type int.
@custlocationID is declared as int.
Can someone help with the apostrophes?