use tempdb;
go
drop
table Test
go
Create
table
Test
(
A int identity primary key,
B NVARCHAR(50
))
insert into Test(B) values ('B') go 50 --插入50条数据 不过和使用循环相比go N的效率要低很多,循环次数很大时还是使用循环为好。
本文介绍了一种在SQL中创建表并批量插入数据的方法,通过对比GO N语句与循环插入的方式,发现循环插入虽然繁琐但在大量数据插入时效率更高。
use tempdb;
go
drop
table Test
go
Create
table
Test
(
A int identity primary key,
B NVARCHAR(50
))
insert into Test(B) values ('B') go 50 --插入50条数据 不过和使用循环相比go N的效率要低很多,循环次数很大时还是使用循环为好。
38万+

被折叠的 条评论
为什么被折叠?