sql server 2005 问题

[复制链接]
查看11 | 回复1 | 2010-7-28 10:36:19 | 显示全部楼层 |阅读模式
我写了一段存储过程是在 SQL SERVER 2005环境下写的:
ALTERPROC [dbo].[SHOW_BOM](@father varchar(20),@TQty numeric(19,6))
as
begin
declare @level int
declare @code varchar(20)
declare @childnum int
declare @quantity numeric(19,6)
-- select @@nestlevel
set @level=@@nestlevel --嵌套层次
if @@nestlevel=-1 --顶层
begin
set @TQty=1
insert z_showbom(code,father,childnum,quantity,level1,level2) select @father,@code,0,1,0,'0'
end

else if @@nestlevel0) Drop table BOMLIST
select IDENTITY(int,1,1) AS ID_Num, t1.* into temp124 from z_showbom t1

select * from temp124
问题:在运行代码2若干次以后,结果的次序是头一次的结果是不一样的,请问大家这是什么问题。

谢谢!

回复

使用道具 举报

千问 | 2010-7-28 10:36:19 | 显示全部楼层
是由于服务器游标的干扰造成的,由于服务器游标性能较低,能不使用时则不要使用,除非避免不了,这是使用游标的前提条件,而且游标由于有操作,所以会导致不同的顺序的!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行