declare @seatnumber int
set @seatnumber=1 
WHILE @seatnumber <=20
begin  
   select AddressID into #tb from TestAddress
   @seatnumber = @seatnumber+1 
end 
drop table #tb
GO为什么我执行这个语句有问题

解决方案 »

  1.   

    CREATE TABLE [T] (
    [id] [int] NULL ,
    [name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL 
    ) ON [PRIMARY]
    GODECLARE @counter smallint
    SET @counter = 0
    WHILE @counter < 100
       BEGIN
          insert T(id,name)
    values(@counter,'aaa')
          SET NOCOUNT ON
          SET @counter = @counter + 1
          SET NOCOUNT OFF
       END
    GOselect * from Tdrop table T
      

  2.   

    declare @seatnumber int
    set @seatnumber=1 
    WHILE @seatnumber <=20
    begin  
       select AddressID into #tb from TestAddress
        set @seatnumber = @seatnumber+1     --少了个set
    end 
    select * from #tb
    drop table #tb
    GO
      

  3.   

    表a
    classID  className     classNumber
    20011231  计算机一班    30
    20011232  计算机二班    25
    表b
    TimeID   TimeDes
    第一场   9:00-10:00
    第二场   11:00-12:00
    要求结果
    classID  TimeID
    20011231  第一场
    ...
    ...
    ...
    (30条)
    20011232 第二场
    ...
    ...
    ...
    (25 条)
      

  4.   

    该协一下:
    declare @seatnumber int
    set @seatnumber=1 
    select AddressID into #tb from TestAddress where 1=2
    WHILE @seatnumber <=20
    begin  
       insert  #tb  select AddressID  from TestAddress
       select @seatnumber = @seatnumber+1 
    end 
    drop table #tb
    GO