- begin
- createtable#table
- (
- theIDintidentity(1,1),
- PriceNamevarchar(1000),
- theDatedatetime,
- Pricesvarchar(1000),
- theCTIDsvarchar(500)
- )
- declare@MyDatedatetime
- DECLAREmycursorCURSORFOR--创建一个游标
- selectdistinctTicketDatefromConceTablewhereTicketID=5
- OPENmycursor
- FETCHNEXTFROMmycursor
- INTO@MyDate
- WHILE@@FETCH_STATUS=0
- BEGIN
- declare@Myid1int,@thePriceNamesvarchar(1000),@thePricesvarchar(5000),@theCTIDvarchar(2000)
- set@thePriceNames=''
- set@thePrices=''
- set@theCTID=''
- DECLAREmycursor1CURSORFOR--创建一个游标
- selectCTIDfromdbo.ConceTablewhereTicketDate=@MyDateorderbyCTID
- OPENmycursor1
- FETCHNEXTFROMmycursor1
- INTO@Myid1
- WHILE@@FETCH_STATUS=0
- BEGIN
- declare@theConcessionsvarchar(100),@thePricevarchar(1000)
- select@theConcessions=ConcessionsfromConceTablewhereCTID=@Myid1
- set@thePriceNames=@thePriceNames+'|'+@theConcessions
- --set@thePriceNames=@theConcessions
- select@thePrice=[TicketPrice]fromConceTablewhereCTID=@Myid1
- --set@thePrices=@thePrices+'|'+@thePrice
- set@theCTID=@theCTID+'|'+CONVERT(varchar(1000),@Myid1)
- set@thePrices=@thePrices+'|'+@thePrice
- --select@Myid1,@thePriceNames,@thePrices,@theConcessions,@thePrice
- FETCHNEXTFROMmycursor1
- INTO@Myid1
- END
- CLOSEmycursor1
- DEALLOCATEmycursor1
- insertinto#tablevalues(@thePriceNames,@MyDate,@thePrices,@theCTID)
- FETCHNEXTFROMmycursor
- INTO@MyDate
- END
- CLOSEmycursor
- DEALLOCATEmycursor
- select*from#table
- droptable#table
- end

被折叠的 条评论
为什么被折叠?



