存储过程更新问题

时间:2011-09-22 01:58:55

标签: sql-server

存储过程工作但没有更新!我认为是关于那些陈述的 如果@ ...<> null。

感谢帮助

   ALTER PROCEDURE [dbo].[sp_UpdateLocation]

    @id_Location char(6),
    @debut_Location smalldatetime,
    @premier_Paiement smalldatetime,
    @nombre_Mensualité char(2),
    @id_Client char(6),
    @no_Termes_location char(6),
    @niv char(20)

AS

BEGIN


IF @nombre_Mensualité  <> null
   BEGIN 

        DECLARE @valeur_auto smallmoney;
        DECLARE @paiment_Mensuel smallmoney;
        SET @valeur_auto= (SELECT valeur FROM Véhicules where niv=@niv )
        SET @paiment_Mensuel= (@valeur_auto/@nombre_Mensualité)

        Update Location  
        SET paiment_Mensuel=@paiment_Mensuel,nombre_Mensualité=@nombre_Mensualité
        WHERE (@id_Location=id_Location)
    END

IF @debut_Location <> null
    BEGIN   
        Update Location  
        SET debut_Location=@debut_Location
        WHERE @id_Location=id_Location
    END

IF @premier_Paiement <> null
        BEGIN   
            Update Location  
            SET premier_Paiement=@premier_Paiement
            WHERE @id_Location=id_Location
        END

IF @id_Client <> null
        BEGIN   
            Update Location  
            SET id_Client=@id_Client
            WHERE @id_Location=id_Location
        END

IF @no_Termes_location <> null
        BEGIN   
            Update Location  
            SET no_Termes_location=@no_Termes_location
            WHERE @id_Location=id_Location
        END

IF @niv <> null
        BEGIN   
            Update Location  
            SET niv=@niv
            WHERE @id_Location=id_Location
        END



      END

      select*from Location

1 个答案:

答案 0 :(得分:1)

而不是<> null尝试IS NOT NULL

MSDN是就这些类型的问题进行咨询的好资源。