自动生成行号
如何自动生成行号
形成表A
ID
1
1
1
2
2
2
3
3
3
4
4
4
100
100
100
.....每个ID有3行,总共100个ID
[解决办法]
这个可以么:
select id=number from master..spt_values where type='p' and number between 1 and 100
union all
select id=number from master..spt_values where type='p' and number between 1 and 100
union all
select id=number from master..spt_values where type='p' and number between 1 and 100 order by id
/*
id
-----------
1
1
1
2
2
2
3
3
3
4
4
4
5
5
5
6
6
6
7
7
7
8
8
8
9
9
9
10
10
10
11
11
11
12
12
12
13
13
13
14
......
92
93
93
93
94
94
94
95
95
95
96
96
96
97
97
97
98
98
98
99
99
99
100
100
100
(300 行受影响)
*/