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 |
|
omeganet
Starting Member
1 Post |
Posted - 2008-10-10 : 12:56:22
|
| Hello everybody. I have the following problem.I have a stored procedure, called sp_GetEventInfo(EventID int). It returns a result with two columns and one row: EventId, EventTitle.I have to create another stored procedure, which takes top 5 rows from two tables and for each row I have to get its EventTitle using the stored procedure. I should return result like this: EventId, EventTitle, StartDate, EndDate. StartDate and EndDate are from the two tables, and the EventTitle is from the stored procedure. How can I do this? I the cursor the best solution? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-10 : 13:01:49
|
it better to create a user defined function rather than current procedure with same logic to return eventid and date. then you could simply useSELECT f.eventid,f.eventdate,{t1/t2}.startdate,{t1/t2}enddatefrom table1 t1join table2 t2on columnscross apply dbo.yourcreatedfn(passingfield)f |
 |
|
|
|
|
|