看了好多资料,还是不知道什么时候能指定返回值,如return 1,用的时候会提示:在此上下文中不能使用带有返回值的 RETURN 语句。

解决方案 »

  1.   

    你是什么情况下得到的错误提示 在此上下文中不能使用带有返回值的 RETURN 语句。比如触发器中就不允许
      

  2.   

    只能在存储过程中使用renturn (1)??
    比如:
    if  (1<2)
    return 1
    select 123
    ..
    这为什么不能返回1呢?
    但:
    if  (1<2)
    return
    select 123
    这个可以执行啊,返回值是0
    能不能看到他的返回值啊?
      

  3.   


    只能在存储过程中使用renturn (1)?? 
    比如: 
    if  (1 <2) 
    return 1 
    select 123 
    这里为什么不能返回指定的值1呢?
      

  4.   


    --存储过程中的 return 主要用于返回存储过程的执行状态。
    create procedure #sp @id int
    as
     return @id;
    godeclare @stat int
    exec @stat=#sp 9
    select @stat
      

  5.   

    查一下联机帮助行了,我就不COPY了