zoukankan      html  css  js  c++  java
  • 今天写的一个存储过程

    1. begin 
    2.     
    3.     create table #table
    4.     (
    5.         theID int identity(1,1),
    6.         PriceName varchar(1000),
    7.         theDate datetime,
    8.         Prices varchar(1000),
    9.         theCTIDs varchar(500)
    10.     )
    11.     
    12.     declare  @MyDate datetime
    13.     DECLARE mycursor CURSOR FOR--创建一个游标
    14.     select distinct TicketDate from  ConceTable where TicketID=5
    15.         OPEN mycursor
    16.         FETCH NEXT FROM mycursor
    17.         INTO @MyDate
    18.         WHILE @@FETCH_STATUS = 0
    19.         BEGIN
    20.     
    21.         declare @Myid1 int,@thePriceNames varchar(1000),@thePrices varchar(5000),@theCTID  varchar(2000)
    22.         set @thePriceNames=''
    23.         set @thePrices=''
    24.         set @theCTID=''
    25.         DECLARE mycursor1 CURSOR FOR--创建一个游标
    26.             select CTID  from dbo.ConceTable where TicketDate =@MyDate order by CTID
    27.             OPEN mycursor1
    28.             FETCH NEXT FROM mycursor1
    29.             INTO @Myid1
    30.             WHILE @@FETCH_STATUS = 0
    31.             BEGIN
    32.             
    33.             declare @theConcessions varchar(100),@thePrice varchar(1000)
    34.             select @theConcessions=Concessions from ConceTable where CTID =@Myid1
    35.             set @thePriceNames = @thePriceNames +'|'+ @theConcessions 
    36.             --set @thePriceNames=@theConcessions
    37.             select @thePrice=[TicketPrice] from ConceTable where CTID =@Myid1
    38.                 --set @thePrices = @thePrices+'|'+@thePrice
    39.             set @theCTID=@theCTID+'|'+CONVERT(varchar(1000),@Myid1)
    40.             set @thePrices= @thePrices+'|'+@thePrice
    41.                 --select @Myid1,@thePriceNames,@thePrices,@theConcessions,@thePrice
    42.                 
    43.            FETCH NEXT FROM mycursor1
    44.            INTO @Myid1
    45.            END
    46.            CLOSE mycursor1
    47.            DEALLOCATE mycursor1
    48.            insert into #table values(@thePriceNames,@MyDate,@thePrices,@theCTID)
    49.             
    50.        
    51.        FETCH NEXT FROM mycursor
    52.        INTO @MyDate
    53.        END
    54.        CLOSE mycursor
    55.        DEALLOCATE mycursor
    56.     select * from #table 
    57.     drop table #table
    58.     
    59. end 
  • 相关阅读:
    hdu 6214 : Smallest Minimum Cut 【网络流】
    hdu 6205: card card card【输入挂】
    UVa 10054 : The Necklace 【欧拉回路】
    hdu 6127 : Hard challenge (2017 多校第七场 1008)(计算几何)
    hdu 6143: Killer Names (2017 多校第八场 1011)
    hdu 6134: Battlestation Operational (2017 多校第八场 1002)【莫比乌斯】
    hdu 4992 Primitive Roots 【求原根模板】
    poj 1284 : Primitive Roots
    codevs 2804 最大最小数质因数
    codevs 2370 小机房的树
  • 原文地址:https://www.cnblogs.com/dingdingmao/p/3146580.html
Copyright © 2011-2022 走看看