insert用法归结有两种,一种是与values连用,一种是与select连用。具体做法有两种:
一、用union
- use db_students
- go
- insert into tb_students(ID,name,sex)
- select '64107010','小平','男' union
- select '64107011','小白','男' union
- select '64107015','小雪','女'
- go
二、用select items form tb_name,从其他表中“导入”数据。
- use db_students
- go
- insert into tb_students(ID,name,sex,birth,classID)
- select * from studentInfo
- go
另外sql 2008支持类似于oracle insert的用法:
- INSERT INTO TestTable (Name, Age) VALUES ('Roy', 25),('中国风', 21);
值得一提的是,在c#中可使用对xml的支持插入多行数据。