第1个回答 2014-04-05
---如果数据库中已经存在test表则,将其drop掉,
if exists (select * from dbo.Sysobjects where id='test' and OBJECTPROPERTY(OBJECT_ID('test'),'IsTable')=1 )
drop table test
--新建数据库
create table test
(
id int
)
declare @i int,@num int --定义变量用来存储循环初始值和结束值
select @i=1,@num=1000
while (@i<=@num) ---进入循环
begin
insert into test values(@i)
select @i+=1
end
select * from test
drop table test --删除实体表,如果程序真用则就不要删除了本回答被提问者采纳