用sql语句插入多条数据
我想往一个表中插入500条相同的数据,请问代码怎么写?
[最优解释]
declare @i int
set @i=1
while @i<=500
begin
---你的语句
insert into TB(...)
values(...)
set @i=@i+1
end
[其他解释]
2008:
insert into xxx
values(xxx)
go 500
insert into tb(col)
select top 500 'col' from sysobjects
IF(OBJECT_ID('TA','U') IS NOT NULL) DROP TABLE TA
CREATE TABLE TA(A INT )
LABLE:
IF((SELECT COUNT(1) FROM TA )<500)
BEGIN
INSERT INTO TA VALUES (1)
END
ELSE
BEGIN
RETURN
END
GOTO LABLE
SELECT COUNT(1) FROM TA