create PROCEDURE App_Customers_Update
@CustomerID int,
@Phone nvarchar(32),
@FamilyTypeID int,
@IDCardNo nvarchar(32),
@CustomerLevel int,
@FamilyTypeName nvarchar(64)


AS
Update Customers
set Phone = @Phone,FamilyTypeID = (select FamilyTypeID from FamilyType where FamilyTypeName = @FamilyTypeName),IDCardNo = @IDCardNo,CustomerLevel = @CustomerLevel
where CustomerID = @CustomerID
RETURN

解决方案 »

  1.   

    应该可以,如果出错把select FamilyTypeID from FamilyType where FamilyTypeName = @FamilyTypeName赋值给一个变量,然后FamilyTypeID=变量
      

  2.   

    就是出错啊,本来FamilyTypeID这列是有值的,这条sql语句把这列变成空值了
      

  3.   

    就是出错啊,本来FamilyTypeID这列是有值的,这条sql语句把这列变成空值了
      

  4.   

    跟踪一下@FamilyTypeName参数的值
    然后在查询分析器下运行这句select FamilyTypeID from FamilyType where FamilyTypeName = 监视得到的值,看看什么结果
      

  5.   

    还有@FamilyTypeName应该是字符串吧??那是否少了''呢??
      

  6.   

    为什么取了@FamilyTypeID 的值没有用?
    反而要通过 @FamilyTypeName这个去关联?
      

  7.   

    把select @a=FamilyTypeID from FamilyType where FamilyTypeName = @FamilyTypeName
    赋值给一个变量
    然后print @a看一下有没有值啊
    最好再跟踪一下传进来的@FamilyTypeName