批量插入数据的问题,求解答
我想往一个表里插入1000条数据,表里原来的数据已排到了004501
我想从004502开始插入
我的语句为:
DECLARE @aa INT
SET @aa = 4502
WHILE 1000
begin
INSERT INTO dbo.DeviceInfo values
(right(10000000+@aa,6),'123456','123456',
'130000000','123456','123456','北京市朝阳区',
'2012-04-11 17:08:35.130','admin',1)
set @aa = @aa + 1
end
但是执行时报错:
Msg 4145, Level 15, State 1, Line 4
An expression of non-boolean type specified in a context where a condition is expected, near 'begin'.
对SQL不熟,高人指教一下。先给100分,问题解决了,再发贴继续给分。
------解决方案--------------------
WHILE 1000
------
这什么 ,
while后接一个布尔表达式。
------解决方案--------------------
DECLARE @aa INT
declare @i int
SET @aa = 4502
set @i = 1
WHILE @i <= 1000
begin
INSERT INTO dbo.DeviceInfo values
(right(10000000+@aa,6),'123456','123456',
'130000000','123456','123456','北京市朝阳区',
'2012-04-11 17:08:35.130','admin',1)
set @aa = @aa + 1
set @i = @i + 1
end