Error messageMsg 156, Level 15, State 1, Line 10Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 12Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 17Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 10Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 12Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 10Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 12Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 17Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 17Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 17Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 17Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 17Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 17Incorrect syntax near the keyword 'and'.Msg 156, Level 15, State 1, Line 18Incorrect syntax near the keyword 'and'.
table structurecreate table #TmpRptData( RegID varchar(10), RptGrp int null, GrpName varchar(20) null, ColName varchar(50) null, subColAmt money null, subColCount int null, ColAmt money null, ColCount int null, EmpID varchar(50))
a piece of codeselect @RegID=upper(@RegID)select @MfilterBy1 =' and TILL_TND_CUR.PRD_AGGR_ID = ' + @BeginPeriodif @PeriodType = 'Today' or @PeriodType = 'Yesterday' select @MfilterBy2 =' TRANS_HEADER.BUS_DT = ''' + substring(@BeginDate,1,10) + ' 12:00:00 AM'''else select @MfilterBy2 =' TRANS_HEADER.BUS_DT between '''+ substring(@BeginDate,1,10) + ' 12:00:00 AM'' and ''' + substring(@EndDate,1,10) + ' 12:00:00 AM'''declare @Qry varchar(8000)