创建Users表并且插入10000条数据,script如下:
use test_Lucy
go
-- 判断如果Users表已经存在,则drop Users表
if exists(select * from sysobjects where name='Users')
drop table Users
-- 创建Users表
create table Users
(
Id int primary key identity(1,1),
Username varchar(8000) not null,
Password varchar(10) not null
)
--插入数据
declare @id int, @username varchar(100), @password varchar(10)
set @id=0
set @username='user'
set @password='abc123_'
while @id<10000
begin
insert into Users(Username,Password)
values (@username+convert(varchar(100),@id),@password) -- int转string也可以用cast(@id as varchar(100)
set @id=@id + 1
end
结果如下: