SQL语句创建表并插入指定N条数据(用于测试)

时间:2020-12-01 23:29:36
CREATE TABLE [dbo].[TestTable](
	[D_Id] [int] IDENTITY NOT NULL,
	[D_Name] [varchar](50) NULL,
	[D_Password] [varchar](32) NULL,
	[D_Else] [varchar](4000) NULL,
	 CONSTRAINT [PK_TestTable] PRIMARY KEY CLUSTERED 
	([D_Id] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
DECLARE @d datetime	
SET @d=getdate()  --计时开始
DECLARE @index INT
SET @index = 1
WHILE @index<50000
BEGIN 
INSERT INTO TestTable(D_Name,D_Password,D_Else)
VALUES('名称','密码测试','其他')
SET @index=@index+1 
END
SELECT [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate()) --计时结束


GO的前面是创建表

后面是插入数据


发此文章仅用于记录在这里,方便下次测试数据拿来用  - -!