Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help needed for html in tsql

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2008-07-03 : 10:32:37
The below code is giving me only one record output
actually it has to give 6 record as out put
after printing one record it should print other records
of 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 code
the below is the rec I am getting as output
I 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>


PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2008-07-03 : 11:02:13
u r assigning the output to a variable so u r getting only the last record..
u need to loop through all the records
Go to Top of Page

aakcse
Aged Yak Warrior

570 Posts

Posted - 2008-07-03 : 13:54:50
Thanks Peter Neo,

Got it, Now I have taken cursor and its printing all the records.

Regards,
Go to Top of Page
   

- Advertisement -