Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 create procedure error

Author  Topic 

marclas
Starting Member

16 Posts

Posted - 2012-05-08 : 00:29:51
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

Marclas

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-05-08 : 00:54:18
[code]
IF @NbreEnregistrement=0
BEGIN
SET @Cmp_Desc ="VERSEMENT INITIAL"
END
ELSE
BEGIN
SET @Cmp_Desc ="COMPLEMENT" + @NbreEnregistrement
END
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

marclas
Starting Member

16 Posts

Posted - 2012-05-08 : 01:00:01
Hi,

Thanks....

Marclas
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-05-08 : 02:31:56
you are welcome


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -