The below code is giving me only one record output actually it has to give 6 record as out putafter printing one record it should print other recordsof the select statement but it is only printing one last record and control is coming out.SELECT @EmailBody = @EmailBody + '<TR><TD>' + CAST(ISNULL (STE_FacilityName,'') AS VARCHAR(MAX)) + '</TD> <TD>' + CAST(ISNULL (STE_RQS_StudioID,'') AS VARCHAR(MAX)) + '</TD> <TD>' + CAST(ISNULL (STE_CNT_ContactID_CreatedBy,'') AS VARCHAR(MAX)) + '</TD> <TD>' + CAST(ISNULL (STE_CreatedDate,'') AS VARCHAR(MAX)) + '</TD> <TD>' + CAST(DATEPART(wk,STE_CreatedDate) AS VARCHAR(2))+ '</TD> <TD>' + CAST(DATENAME(DW,STE_CreatedDate) AS VARCHAR(12))+ '</TD> ' FROM TBL_SiteMaster sm INNER JOIN LK_RequestingStudio rs ON sm.STE_RQS_StudioID = rs.RQS_StudioID INNER JOIN TBL_UserContacts uc ON sm.STE_CNT_ContactID_CreatedBy = uc.CNT_ContactID WHERE CAST(DATEPART(wk,STE_CreatedDate) AS VARCHAR(2) )= @weekNum --@weekNum ORDER BY STE_CreatedDate ASC
If required I can send complete sp.kindly help me in debugging this codethe below is the rec I am getting as outputI dont understand as to why it is getting terminated after printing one rec. <TR><TD>pete-sony</TD> <TD>2</TD> <TD>10</TD> <TD>Mar 1 2008 7:22AM</TD> <TD>9</TD> <TD>Saturday</TD>