一次向SQL Server Insert多条记录的方法

如果需要一次向SQL Server Insert多条记录,SQL语句应该怎么写呢?下面就将为您介绍一次向SQL Server Insert多条记录的方法,供您参考,希望对您学习SQL Server Insert语句能够有所帮助。

如下题目为:

在学生表内添加如下记录
95001,李勇,男,20,CS
95002,刘晨,女,19,IS
95003,王敏,女,18,IS
95004,张立,男,19,MA
96001,徐一,男,20,IS
96002,张三,女,21,CS
96003,李四,男,18,IS

具体代码为:

 
 
 
  1. Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '95001','李勇','男','20','CS'  
  2. Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '95002','刘晨','女',19,'IS'   
  3. Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '95003','王敏','女',18,'IS'   
  4. Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '95004','张立','男',19,'MA'   
  5. Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '96001','徐一','男',20,'IS'   
  6. Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '96002','张三','女',21,'CS'   
  7. Insert into Student(Sno,Sname,Ssex,Sage,sdept) select '96003','李四','男',18,'IS'   
  8.  

 

 

 

【编辑推荐】

教您如何使用SQL中的函数替代游标

SQL中的分析函数

创建SQL函数的实例

SQL中DATENAME函数的用法

SQL中循环语句的效果实例

THE END