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 |
csaville
Starting Member
1 Post |
Posted - 2010-05-19 : 18:56:24
|
I have a cursor which does the following:Table AOptionID StartDate AllocationID NumberOfNights1003 2009-04-24 0:00:00.0 200 31003 2009-04-24 0:00:00.0 210 3While @vloopCounter is less than the @vNumberOfNights we insert a row with the initial StartDate and ensuing dates into a new table. (The business logic is to know what has been allocated on any specific date.) WHILE @@FETCH_STATUS = 0BEGINSET @vloopCounter = 0 PRINT @vBookedOptionID WHILE @vloopCounter < @vNumberOfNights BEGIN SELECT @vThisDate = @vServiceStartDate + @vloopCounterTable BOptionID UsageDate AllocationID1003 2009-04-24 0:00:00.0 2001003 2009-04-25 0:00:00.0 2001003 2009-04-26 0:00:00.0 2001003 2009-04-24 0:00:00.0 2101003 2009-04-25 0:00:00.0 2101003 2009-04-26 0:00:00.0 210The cursor is taking forever to run and I have been tasked with creating an SSIS package. Any suggestions??Sample dataOptionID StartDate AllocationID NumberOfNights1001 2009-06-12 0:00:00.0 100 21001 2009-06-12 0:00:00.0 101 21002 2009-06-16 0:00:00.0 110 21002 2009-06-16 0:00:00.0 115 21003 2009-04-24 0:00:00.0 200 31003 2009-04-24 0:00:00.0 210 3ResultsOptionID UsageDate AllocationID1001 2009-06-12 0:00:00.0 1001001 2009-06-13 0:00:00.0 1001001 2009-06-12 0:00:00.0 1011001 2009-06-13 0:00:00.0 1011002 2009-06-16 0:00:00.0 1101002 2009-06-17 0:00:00.0 1101002 2009-06-16 0:00:00.0 1151002 2009-06-17 0:00:00.0 1151003 2009-04-24 0:00:00.0 2001003 2009-04-25 0:00:00.0 2001003 2009-04-26 0:00:00.0 2001003 2009-04-24 0:00:00.0 2101003 2009-04-25 0:00:00.0 2101003 2009-04-26 0:00:00.0 210 |
|
|
|
|