插入的是后面那个  list2.list(i) 里的i 值

解决方案 »

  1.   

    哦,*^_^*......
    我还真的不知道这个select List2.List(i)后面带个括号是啥意思,这个语法好像不对
      

  2.   

    但,List2.List(i)怎能用在SQL语句中!
      

  3.   

    insert into 
    table (id)
    values (id1)这是用insert插入一条语句的语法insert into table
    select 
    后面这个select 能查询出多少符合条件的记录,这个语法就能把这些记录插到table中去
      

  4.   

    NOKIA_LIU(小黑)说的是对,可是楼主问的不是这样,他问的是:
    insert WareHouse_M_QkdPrint_Order(编号) select List2.List(i)
      

  5.   

    我問的就是NOKIA_LIU(小黑)説的那樣
    NOKIA_LIU(小黑)的意思是不是可以同時插入select後面的多條數據?比如select……一共有100筆數據,那麽用一條insert就能插入100筆數據嗎?
      

  6.   

    chuanyi() ,你的问题insert WareHouse_M_QkdPrint_Order(编号) select List2.List(i)
    的语法是不对的,没有select List2.List(i),只有insert into table select * from otherTable你的select List2.List(i)--〉没有这样的select!如果是insert into table select * from otherTable,当然是select出来多少数据就可以插入多少条,这个T-SQL可以做到的!
      

  7.   

    MorningTea(一勺抹茶),谢谢,List2.List(i)是VB中的语法,不是和SQL一起使用的,会有一个相应的转换
    我想多问一下,insert into table select * from otherTable,那么table和othertable的表结构需要相同吗?
      

  8.   

    如果是創建臨時表的話
    它會自動的創建一個相同的數據表
    如果是手建表的話你肯定table和othertable
    的表结构需要相同了不然的插進去時要出錯
      

  9.   

    1。
    insert into table select 字段 from othertable
    至少select 字段 from othertable查到的字段个数跟结构应该跟table的一样。
    这样就可以。
    2。
    insert into table select 静态值
    也是可以的。只要个数和类型一样!
      

  10.   

    to:楼主
    你后面那条select * from table where 条件
    你这条语句能查询出来多少符合条件的记录那是你自己又条件来控制的。
    insert into table
    select 
    这语法就可以把你查询出来所有的记录都插进去!如果有过有这样的情况
    insert into table
    ('id1','id2','id3','id4','id5','id6')
    select 'id1','id2','id3',xx,'id5',cc)from table where 条件
    这就是插入记录的时候某个字段直接设定如(XX,CC)等。不过只需要注意引号的使用就OK了。。