I have the following code which gives me the error shown, it seems to me that I am misplacing some quotes.
Declare '@Cuenta Varchar(25),@Fecha Varchar(10),@Moneda Varchar(3),@User Varchar(20)'
Declare '@NomTabla Varchar(60)'
SET @User = 'Usuario'
SET @Cuenta ='190106010105'
SET @Fecha ='20170812'
SET @Moneda = 'SOL'
SET @NomTabla = '##RptMayorDetalle' + @User
EXEC ('SELECT * FROM Contabilidad..Comprobante WHERE FOLIO LIKE'+ @Fecha+' + ''%''')
I get the error:
Msg 4145, Level 15, State 1, Line 1
A non-Boolean expression was specified in a context where a condition was expected, close to LIKE20170812
.