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可以做到的!
MorningTea(一勺抹茶),谢谢,List2.List(i)是VB中的语法,不是和SQL一起使用的,会有一个相应的转换 我想多问一下,insert into table select * from otherTable,那么table和othertable的表结构需要相同吗?
1。 insert into table select 字段 from othertable 至少select 字段 from othertable查到的字段个数跟结构应该跟table的一样。 这样就可以。 2。 insert into table select 静态值 也是可以的。只要个数和类型一样!
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了。。
我还真的不知道这个select List2.List(i)后面带个括号是啥意思,这个语法好像不对
table (id)
values (id1)这是用insert插入一条语句的语法insert into table
select
后面这个select 能查询出多少符合条件的记录,这个语法就能把这些记录插到table中去
insert WareHouse_M_QkdPrint_Order(编号) select List2.List(i)
NOKIA_LIU(小黑)的意思是不是可以同時插入select後面的多條數據?比如select……一共有100筆數據,那麽用一條insert就能插入100筆數據嗎?
的语法是不对的,没有select List2.List(i),只有insert into table select * from otherTable你的select List2.List(i)--〉没有这样的select!如果是insert into table select * from otherTable,当然是select出来多少数据就可以插入多少条,这个T-SQL可以做到的!
我想多问一下,insert into table select * from otherTable,那么table和othertable的表结构需要相同吗?
它會自動的創建一個相同的數據表
如果是手建表的話你肯定table和othertable
的表结构需要相同了不然的插進去時要出錯
insert into table select 字段 from othertable
至少select 字段 from othertable查到的字段个数跟结构应该跟table的一样。
这样就可以。
2。
insert into table select 静态值
也是可以的。只要个数和类型一样!
你后面那条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了。。