笔记77 插入数据基数行偶数行

笔记77 插入数据基数行偶数行

 1 --插入数据基数行偶数行
 2 USE pratice
 3 DECLARE @MyCounter INT
 4 DECLARE  @rownumber INT
 5 SET @MyCounter = 1 /*设置变量*/
 6 SET @rownumber =0
 7 
 8 WHILE @MyCounter <=10  --执行3次,第一次@MyCounter <300000 30W条记录 第二次@MyCounter <300000 60W条记录 第三次@MyCounter <400000 40W条记录
 9 BEGIN
10 
11 SELECT TOP 1 @rownumber= a FROM dbo.test ORDER BY a DESC
12 IF   (@rownumber+1)%2<>0
13 INSERT INTO dbo.test
14 SELECT @MyCounter,'坏人','2011-8-1 21:21:00','基数',@MyCounter
15 ELSE
16 INSERT INTO dbo.test
17 SELECT @MyCounter,'坏人','2011-8-2 21:21:00','偶数',@MyCounter
18 
19 SET @MyCounter = @MyCounter + 1
20 END
21 
22 --看一下现在表有多少条记录
23 --SELECT COUNT(*) FROM dbo.test
24 
25 --DELETE FROM dbo.test
26 SELECT * FROM dbo.test

 

posted @ 2013-08-02 23:00 桦仔 阅读(...) 评论(...) 编辑 收藏