代码改变世界

sqlserver 2008 R2 方便插入多行数据

2012-06-15 11:16  java环境变量  阅读(464)  评论(0编辑  收藏  举报

今天看同事插入几百行数据,N多insert into累啊!

SELECT DISTINCT '('+'''' +loginip  +''''+')'+',' FROM dbo.Login
WHERE loginname  IN
(
SELECT  DISTINCT loginname FROM dbo.Login
WHERE loginip='61.170.245.61'
)
go

--获得这样的结果
('61.61.245.243'),
('61.61.245.61'),

 

这样直接

insert into testip values
('1.192.47.125'),
('1.58.113.154'),
('1.85.189.111'),
('1.86.37.156'),
('101.84.100.87'),
('106.83.49.191') 效率高点!