有人知道这是为什么吗?
--直接执行下面语句,观察结果
set rowcount 0
if exists(select name from sysobjects where name = 'temp1') drop table temp1
if exists(select name from tempdb..sysobjects where xtype = 'U') drop table #temp
create table temp1
(
cust_id char(16)
)
insert temp1 values(1)
insert temp1 values(2)
insert temp1 values(3)
insert temp1 values(4)
insert temp1 values(5)
insert temp1 values(6)
insert temp1 values(7) --把这句话注释的话,返回结果就是2,1,为什么会这样呢???
go
--把上面这个go注释掉的话,返回结果就是2,1,这又是为什么呢???
set rowcount 3
select * into #temp from temp1
where convert(numeric(16,0),cust_id) < 5
order by convert(numeric(16,0),cust_id) desc
select * from #temp
go
--我的数据库是mssqlserver2000,安装时选择的是二进制排序