数据库版本 SQL Server 2008

如果需要往数据库中插入100万条记录,那个时候插入记录我是用C#写的,后来发现,其实用SQL自已也可以实现的,而且更简单效率更高!

看示例

 

create proc proc_Prvalue
as
declare @i int
set @i=1
while @i<=1000000
begin
	insert into Products( Name, Price, Works, typeid) values('羽绒服','210','冬季必备',1)
	set @i=@i+1
end
go

exec proc_Prvalue --调用

 

 执行该存储过程,将在表 Products中 添加10W条数据,比在程序中写 循环要好很多哦!

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-11-24
猜你喜欢
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案