Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Cursors and inserting rows

Status
Not open for further replies.

ehenry

Programmer
Sep 18, 2009
65
US
I have a table that contains trade deals, there are some trades known as Strips that come in as one deal, however they need to be displayed as if they were multiple deals. For example a Jul-10 - Aug-10 Strip would show up as one row in the table, I need to display this as two rows with the same information, but one for Jul-10 and one for Aug-10. I have a detailed spreadsheet with some sample data to show exactly what I am trying to achieve. So far I am pulling only the Strip Deals from the table and placing them in a Table Variable. I am assuming I would use a cursor to add rows to the Table Variable and then Select from that the Data I want to Display. I would like to know if there is some better way of doing this. Thank you.
 
Try this
Code:
Select StartDate,* 
from Treaddeals
Union
Select EndDate,* 
from Treaddeals

 
That wont work, The Strips can be more than just 2 Months. You could have Mar-10 - Jun-10 with a startdate of 3/1/2010 and an enddate of 6/30/2010. That would leave out the months in between. I should have Explained that. Thanks though.
 
Could you please post some example data and what you want as a result from it?

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
You would need a calander table and join on Calander date between StartDate And EndDate


Code:
Select * 
from Treaddeals
inner join calander 
on Calanderdate Between StartDate and EndDate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top