22,209
社区成员
发帖
与我相关
我的任务
分享
CREATE TABLE [dbo].[T2](
[id] [int] NULL,
[col1] [char](5) COLLATE Chinese_Taiwan_Bopomofo_CI_AS NULL,
[col2] [char](5) COLLATE Chinese_Taiwan_Bopomofo_CI_AS NULL
) ON [PRIMARY]
go
declare @i int
set @i=1
while (@i<5)
begin
insert t2
select @i,cast (@i as varchar)+'a',cast (@i as varchar)+'0b'
set @i=@i+1
end
go
insert t2
select 0,'0a','0b'
go
select top 100 * from t2
select top 100 id from t2
select top 100 id from t2 order by id
go
/*
id col1 col2
----------- ----- -----
1 1a 10b
2 2a 20b
3 3a 30b
4 4a 40b
0 0a 0b
(5 行受影响)
id
-----------
1
2
3
4
0
(5 行受影响)
id
-----------
0
1
2
3
4
(5 行受影响)
*/
create nonclustered
index IX_1 on t2(id asc)
select top 100 * from t2
select top 100 id from t2
select top 100 id from t2 order by id
/*
id col1 col2
----------- ------ ------
1 1a 10b
2 2a 20b
3 3a 30b
4 4a 40b
0 0a 0b
(5 行受影响)
id
-----------
0
1
2
3
4
(5 行受影响)
id
-----------
0
1
2
3
4
(5 行受影响)
*/