我没有跟踪调试!因为我不知道怎么跟踪!初学者,不好意思!^_^!
zcjl : 
  stdm(试题代码)  stlx(试题类型)  kzbh(课程编号)  yhm(用户名) yhlx(用户类型) sfzq (是否正确)
xscsjl:和zcjl一样
 jctxms:
  sttx(试题类型) txmc(试题类型名称) dybm(试题所在的表名称)
试题所在表的结构:stdm (试题代码)mc(名称) 
以上是用到的表中主要字段!

解决方案 »

  1.   

    SQL 2000查询分析器
    --左连的对象浏览器(没有的话按F8)
    --对象项中
    --右键调试的存储过程
    --调试
    --输入参数(必须输入所有的参数,包括默认值/输出参数
    --点击执行
    --出现一个浮动工具条
    --上面有单步执行,断点设置等按F11是单步执行.如果要运行到指定行,只需要将光标移动到指定的行,再按Ctrl+F10
      

  2.   

    create procedure msp_cstj
     ( @ClassID char(4) ) As  
    Begin  
     SET NOCOUNT OFF  
      
     declare @mySql varchar(1024)  
     declare @stlx char(1),@stdm varchar(20),@mSfzq char(1),@mCwcs int  
     declare @TabName varchar(20)  
     declare @OldStdm varchar(20),@OldStlx char(1)  
      
     if exists(Select 1 from sysobjects where name = 'Ls_TabTF' and type = 'U') 
         drop table Ls_TabTF    Create table Ls_TabTF (stdm varchar(20),mc varchar(2000),cwcs char(6)) if exists(Select 1 from sysobjects where name = 'Ls_TabJL' and type = 'U' )
         drop table Ls_TabJL  Create table Ls_TabJL (stdm varchar(20),stlx char(1),sfzq char(1))

         select @mySql = 'Insert into Ls_TabJL select stdm,stlx,sfzq from zcjl where sfzq = 0 and kbh = '''+@ClassID+''''
         execute(@mySql)
         select @mySql = 'Insert into Ls_TabJL select stdm,stlx,sfzq from xscsjl where sfzq = 0 and kbh = '''+@ClassID+''''
         execute(@mySql)
      
     select @mCwcs = 1  
     select @OldStdm = ''
     select  @OldStlx = ''
     
     declare cur_tx cursor for  select * from Ls_TabJL 
     open cur_tx  
     fetch cur_tx into @stdm,@stlx,@msfzq
       while @@fetch_status = 0  
           Begin  
    /***********改了这里***************/
    if not exists(select 1 from Ls_TabJL where stdm=''''+@stdm+'''')
    /************改了这里***************/
       begin 
     select @mCwcs = 1  
     select @TabName = dybm from jctxms where sttx = @stlx  
         select @mySql = 'Insert Into Ls_TabTF select stdm, tm,''' + convert(char(10),@mCwcs) + ''' from ' + @TabName + ' where stlx = ''' + @stlx + ''' and stdm = ''' + @stdm + ''''  
       end
           else  
       begin   
         select @mySql = 'update Ls_TabTF set cwcs =convert(char(10),convert(int(4)/*这里错了,int类型不用指定长度 */,cwcs)+1)  where stdm ='''+@stdm+'''' 
           end
      
      
      Execute(@mySql)  
       select @OldStdm = @stdm
       select @OldStlx = @stlx
       fetch cur_tx into @stdm,@stlx,@msfzq  
         End  
      
     Close cur_tx  
     Deallocate cur_tx  
       
     select * from Ls_TabTF order by cwcs desc 
      
     SET NOCOUNT ON  
    End  
      
    go