CREATE PROCEDURE dbo.Z3prifix_1
(
   @hid_fix_dan int,
   @hpri_fix    float  output,
   @hfix_time   float
)
AS
BEGIN
    select  
        @hpri_fix = @hfix_time * a.gpay_hour 
    from 
        Z3 a,Z2 b 
    where
        a.hid_no = b.gid_no
        and
        a.hid_fix_dan = @hid_fix_dan
    
    return
END
GO

解决方案 »

  1.   

    try:select  @hpri_fix = @hfix_time * (SELECT gpay_hour
                                        FROM dbo.Z2 
                                          WHERE gid_no=dbo.Z3.hid_no)
    from Z3
    where hid_fix_dan = @hid_fix_dan
      

  2.   

    请教楼上:
    是不是select后面不能跟子查询的?
      

  3.   

    libin_ftsafe(子陌红尘)  我想问下a.gpay_hour在那里声明?
     vivianfdlpw() 你的还是不行
      

  4.   

    a.gpay_hour 的前缀 a 为表 Z3 的别名,a.gpay_hour 其实就是 Z3.gpay_hour 。
      

  5.   

    视图更合适。
    当然,你也可以用存储过程的。CREATE view v3      -- 修理费
      as
      select 修理作业表.RID  RID,  --   修理作业表的序号
             工资表.工资 * 修理作业表.修理时间 RepairFee
        from 修理作业表 left outer join 工资表 on 修理作业表.工号=工资表.工号