declare @n int
set @n=(select top 1 colname from table1)
insert into table2(colname) values(@n)

解决方案 »

  1.   

    create  procedure update_follow
    asDeclare @personid as varchar(50)Declare personid_cursor2 cursor for select personid from f_person
    open personid_cursor2fetch next from personid_cursor2 into @personidwhile @@fetch_status=0
    begin
           declare @name varchar(50)
           select @name=name from f_person where personid=@personid  
           update f_follow set name=@name where personid=@personid
           fetch next from  personid_cursor2 into @personid
    endclose personid_cursor2GO
    ///////////////////////////////////////////////////
    此存储过程:
    表f-person和表f-follow有相同的列name
    他们相关联的是personid
    把表f-person的name   放到   表f-follow的name
      

  2.   

    insert into table1(a1,a2)
    select b1,b2 from table2
    where  ................                    ok!!!!
      

  3.   

    insert into table1(a1,a2)
    select b1,b2 from table2
    where  b1 not in (select a1 from table1 )
    and    b2 not in (select a2 from table2 )  
    and .........
      

  4.   

    更正:clb2001->sorryinsert into table1(a1,a2)
    select b1,b2 from table2
    where  b1 not in (select a1 from table1 )
    and    b2 not in (select a2 from table2 )  
    and .........