有人知道这是为什么吗?

zhousw 2003-06-10 12:00:22
--直接执行下面语句,观察结果
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,安装时选择的是二进制排序
...全文
37 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
layeryli 2003-06-10
  • 打赏
  • 举报
回复
不管怎么样,出来的都是3、2、1
zjcxc 元老 2003-06-10
  • 打赏
  • 举报
回复
我是winserver 2003+sql2000企业版(默认安装)+sp3
zjcxc 元老 2003-06-10
  • 打赏
  • 举报
回复
应该是你的问题,我这里,怎么处理结果都是:
4
3
2
nik_Amis 2003-06-10
  • 打赏
  • 举报
回复
我这里怎么样都是

4,3,2
joygxd 2003-06-10
  • 打赏
  • 举报
回复
这跟注释没有关吧

我这都是
cust_id
----------------
3
2
1
pbsql 2003-06-10
  • 打赏
  • 举报
回复
我这里出来的都是:(那两句注释不注释都一样)

cust_id
----------------
3
2
1
j9988 2003-06-10
  • 打赏
  • 举报
回复
我这返回都是4,3,2
可能是你系统有问题。装SP了吗?
pengdali 2003-06-10
  • 打赏
  • 举报
回复
我这里加不加go出来的都是:

cust_id
----------------
4
3
2
DJMPH 2003-06-10
  • 打赏
  • 举报
回复
说对了。
Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows NT 5.0 (Build 2195: Service Pack 3)
4
3
2
Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48 Copyright (c) 1988-2000 Microsoft Corporation Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 3)
3
2
1
layeryli 2003-06-10
  • 打赏
  • 举报
回复
321的朋友们快装sp3吧
happydreamer 2003-06-10
  • 打赏
  • 举报
回复
我试了,结果也是对的啊
Happiness 2003-06-10
  • 打赏
  • 举报
回复
cust_id
----------------
3
2
1
pbsql 2003-06-10
  • 打赏
  • 举报
回复
可能是BUG,into到临时表就会出现你说的那样,直接select出来就正确:
select * from temp1
where convert(numeric(16,0),cust_id) < 4
order by convert(numeric(16,0),cust_id) desc
CrazyFor 2003-06-10
  • 打赏
  • 举报
回复
还是不知道你是什么问题.:)
pengdali 2003-06-10
  • 打赏
  • 举报
回复
cust_id
----------------
3
2
zhousw 2003-06-10
  • 打赏
  • 举报
回复
我装了sp3后问题解决.谢谢各位!
zhousw 2003-06-10
  • 打赏
  • 举报
回复
--不好意思,应该是set rowcount 2时有这个情况的.现在改正,大家再试


--直接执行下面语句,观察结果
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 2
select * into #temp from temp1
where convert(numeric(16,0),cust_id) < 4
order by convert(numeric(16,0),cust_id) desc
select * from #temp
go

zhousw 2003-06-10
  • 打赏
  • 举报
回复
--不好意思,应该是set rowcount 2时有这个情况的.现在改正,大家再试
--直接执行下面语句,观察结果
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 2
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,安装时选择的是二进制排序
愉快的登山者 2003-06-10
  • 打赏
  • 举报
回复
--insert temp1 values(7) --把这句话注释的话,返回结果就是2,1,为什么会这样呢???
--go
结果:
cust_id
----------------
4
3
2

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧