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.
| Author |
Topic |
|
ameya_amu
Starting Member
25 Posts |
Posted - 2007-03-27 : 11:54:46
|
| i am preparing module like email which contain subject, content, enclosure, etc and this mail is forwarded to many persons. if person A create a mail and forward it to B and then B makes some remark and forwad it to C.i have created 2 table 1)MainMail 2)forwardedMailMainMail ContentMidFromTo SubjectContentEnclForwarded ContentFidMidFromToRemarkforwarded table is displayed as thisFid Mid From To Remark1 1 A B Tsds2 1 B C fdgdf3 1 C D jgjg4 1 D B jhjkh5 1 B A hjghji want following output in single query1) Subject(from MainMail):- test Content(from MainMail):- te From To Remark A B Tsds B C fdgdf C D jgjg D B jhjkh B A hjghjand following output in another query the hierarky in which mai is been forwardedABCDBAPlz help me |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-03-27 : 12:37:49
|
| The second bitselect [From] from(select [From], Fid from forwarded where Mid = 1union allselect top 1 [To], Fid+1 from forwarded where Mid = 1 order by Fid desc) aorder by FidThe first bit depends on what format you want the result.3 resultsets? 1 resultset with unused columns? 1 resultset with duplicated values? 2 output parameters and a resultset?for the lastcreate proc s_GetMail@Mid int ,@subject varchar(100) out ,@content varchar(1000) outasselect @subject = subject, @content = content from MainMail where Mid = @Mid select [From], [To], Remark from forwarded where Mid = @Mid order by Fidgo==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|