how to view the generated string of @finalquery?
DECLARE @finalQuery nvarchar(MAX)
SET @finalQuery=@QUERY + @whereField + @criteriaSelected + ' DATEADD(day,0,COMPANY.date), 0) >'''+ convert(varchar(50),@m_fromdate,101) +''' AND DATEADD(day,DATEDIFF(day, 0, COMPANY.date), 0) <='''+ convert(varchar(50),@m_todate,101) +''' AND DATEADD(day, DATEDIFF(day, 0, lastupdateddate), 0)>'''+ convert(varchar(50),@m_updatefromdate,101) +''' AND DATEADD(day, DATEDIFF(day, 0, lastupdateddate), 0)>'''+ convert(varchar(50),@m_updatetodate,101) +''' AND COMPANY.active ='+CAST(@m_active AS NVARCHAR(30)) +' '