syntax error : Msg 102, Level 15, State 1, Procedure CreerComplement, Line 43

  • hi,

    I have this procedure

    CREATE PROCEDURE dbo.CreerComplement

    -- Add the parameters for the stored procedure here

    @CMP_ID uniqueidentifier = '00000000-0000-0000-0000-000000000000' OUTPUT,

    @Dos_ID uniqueidentifier,

    @Cmp_NoBr nvarchar (50),

    @Cmp_Desc nvarchar (50),

    @Cmp_verse money,

    @Node nvarchar (50)

    AS

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    IF @CMP_ID IS NULL OR @CMP_ID = '00000000-0000-0000-0000-000000000000'

    BEGIN

    set @CMP_ID = NEWID ()

    END

    -- Insert statements for procedure here

    UPDATE dbo.CSR_COMPLEMENT

    SET CMP_ID = @CMP_ID , DOS_ID =@Dos_ID ,CMP_NOBR =@Cmp_NoBr ,

    CMP_DESC =@Cmp_Desc , CMP_MTVERSE =@Cmp_verse , CMP_DATE = CURRENT_TIMESTAMP

    WHERE CMP_ID = @CMP_ID

    IF @@ROWCOUNT =0

    BEGIN

    ---verifions le nbre d'enregistrement pour ce dossier

    ---2: cptons le nbre d'enregistrement pour ce dos

    DECLARE @NbreEnregistrement int

    set @NbreEnregistrement =(SELECT COUNT (DOS_ID) FROM CSR_COMPLEMENT

    WHERE CSR_COMPLEMENT.DOS_ID = (SELECT dbo.CSR_DOSSIER.DOS_ID

    FROM dbo.CSR_DOSSIER WHERE DOS_NODE =@node))

    IF @NbreEnregistrement=0

    BEGIN

    @Cmp_Desc ="VERSEMENT INITIAL"

    END

    ELSE

    BEGIN

    @Cmp_Desc ="COMPLEMENT" + @NbreEnregistrement

    END

    INSERT INTO CSR_COMPLEMENT

    VALUES(@CMP_ID ,(SELECT dbo.CSR_DOSSIER.DOS_ID

    FROM dbo.CSR_DOSSIER WHERE DOS_NODE =@node ),@Cmp_NoBr ,@Cmp_Desc ,@Cmp_verse ,CURRENT_TIMESTAMP )

    END

    END

    but just after the If instructions i have this error

    Msg 102, Level 15, State 1, Procedure CreerComplement, Line 43

    Syntaxe incorrecte vers '@Cmp_Desc'.

    Msg 102, Level 15, State 1, Procedure CreerComplement, Line 47

    Syntaxe incorrecte vers '@Cmp_Desc'.

    Msg 156, Level 15, State 1, Procedure CreerComplement, Line 55

    Syntaxe incorrecte vers le mot clé 'END'.

    Can somebody please give me a hand?

    I have looked all over and i can't understand why this error

    thanks

  • This is the edited procedure:

    CREATE PROCEDURE dbo.CreerComplement

    -- Add the parameters for the stored procedure here

    @CMP_ID uniqueidentifier = '00000000-0000-0000-0000-000000000000' OUTPUT,

    @Dos_ID uniqueidentifier,

    @Cmp_NoBr nvarchar (50),

    @Cmp_Desc nvarchar (50),

    @Cmp_verse money,

    @Node nvarchar (50)

    AS

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    IF @CMP_ID IS NULL OR @CMP_ID = '00000000-0000-0000-0000-000000000000'

    BEGIN

    set @CMP_ID = NEWID ()

    END

    -- Insert statements for procedure here

    UPDATE dbo.CSR_COMPLEMENT

    SET CMP_ID = @CMP_ID , DOS_ID =@Dos_ID ,CMP_NOBR =@Cmp_NoBr ,

    CMP_DESC =@Cmp_Desc , CMP_MTVERSE =@Cmp_verse , CMP_DATE = CURRENT_TIMESTAMP

    WHERE CMP_ID = @CMP_ID

    IF @@ROWCOUNT =0

    BEGIN

    ---verifions le nbre d'enregistrement pour ce dossier

    ---2: cptons le nbre d'enregistrement pour ce dos

    DECLARE @NbreEnregistrement int

    set @NbreEnregistrement =(SELECT COUNT (DOS_ID) FROM CSR_COMPLEMENT

    WHERE CSR_COMPLEMENT.DOS_ID = (SELECT dbo.CSR_DOSSIER.DOS_ID

    FROM dbo.CSR_DOSSIER WHERE DOS_NODE =@node))

    IF (@NbreEnregistrement=0)

    BEGIN

    Set @Cmp_Desc ='VERSEMENT INITIAL'

    END

    ELSE

    BEGIN

    Set @Cmp_Desc ='COMPLEMENT' + @NbreEnregistrement

    END

    INSERT INTO CSR_COMPLEMENT

    VALUES(@CMP_ID ,(SELECT dbo.CSR_DOSSIER.DOS_ID

    FROM dbo.CSR_DOSSIER WHERE DOS_NODE =@node ),@Cmp_NoBr ,@Cmp_Desc ,@Cmp_verse ,CURRENT_TIMESTAMP )

    END

    END

    Following were the errors:

    Msg 102, Level 15, State 1, Procedure CreerComplement, Line 43

    Syntaxe incorrecte vers '@Cmp_Desc':

    In SQL Server you pass value into a temporary variable using the syntax

    -- Set @Cmp_Desc ='VERSEMENT INITIAL'

    OR

    Select @Cmp_Desc = 'VERSEMENT INITIAL'

    And not like this

    @Cmp_Desc ='VERSEMENT INITIAL'

    Msg 102, Level 15, State 1, Procedure CreerComplement, Line 47

    Syntaxe incorrecte vers '@Cmp_Desc':

    Same error as above.

    Replace

    @Cmp_Desc ='COMPLEMENT' + @NbreEnregistrement

    With

    Set @Cmp_Desc ='COMPLEMENT' + @NbreEnregistrement

    OR

    Select @Cmp_Desc ='COMPLEMENT' + @NbreEnregistrement

    Hope its running now

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

  • hi,

    Yes it does!!!

    thks

  • marclas (5/7/2012)


    hi,

    Yes it does!!!

    thks

    You're Welcome:-)

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply