Consider the following TSQL:
SET @WhereClause1 = 'where a.Date > ' + @InvoiceDate
I get a date/string conversion error. @InvoiceDate
is a datetime variable. What is the right syntax?
This might work.
SET @WhereClause1 = 'where a.Date > ''' + convert(varchar, @InvoiceDate) + ''''
although an error will be raised if the value is null.