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 2000 Forums
 SQL Server Development (2000)
 incorrect syntax error

Author  Topic 

Landie
Starting Member

8 Posts

Posted - 2008-08-18 : 09:48:27
I have another stored proecedure where I always get this error :
"Error 170 : line 25: Incorrect syntax near '''. (at least, that's where I think it mentions, the syntax near-part is not that clear to see).

This is the stored procedure:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

/* Record in KBODossier aanmaken
Input: keyid klant, keyid hoofdonderneming (voor vestigingen), dossiertype, medewerker, persoonstype
Output : dossiernr
*/

CREATE PROCEDURE ULNV_KBODossier
@Keyid numeric(9,0),
@KeyidHoofd numeric(9,0),
@DossType int,
@PersType varchar(3),
@MDWNr numeric(9,0),
@KBODossNr numeric(9,0) OUTPUT
AS

-- variabelen
DECLARE @PersoonType int

BEGIN
IF @PersType = 'NP' SET @PersoonType = 1
IF @PersType = 'RP' SET @PersoonType = 2
IF @PersType = 'VNP' SET @PersoonType = 4
IF @PersType = 'VRP' SET @PersoonType = 5

INSERT INTO svf.dbo.KBODossier(KeyID, KeyidHoofd, DossType, IngaveDatum, Status, StatusID, StatusDatum, Medewerker,
PersType) VALUES (@KeyID,@Keyidhoofd, @DossType, getdate(),’Nieuw’,1,getdate(),@MDWNr, @PersoonType)

SET @KBODossNr = (SELECT KBODossnr FROM svf.dbo.KBODossier WHERE keyid = @Keyid
and Medewerker = @MDWNr and dosstype = @DossType and PersType = @PersType)

END

GO


The strange thing is that if i delete the 4 if's, I still get the error but then on line 22 (the empty line just before BEGIN).

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-18 : 09:52:37
what are values you passed for variables?
Go to Top of Page

Landie
Starting Member

8 Posts

Posted - 2008-08-18 : 09:55:45
I haven't even executed this stored procedure. I get the errors when I check the syntax creating a stored procedure.

If I would use the stored proecedure these would be possible variables :
@Keyid : 40123256
@KeyidHoofd : 41987352
@DossType : 1
@PersType : 'NP' or 'RP' or 'VRP' or 'VNP'
@MDWNr : 19000123

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-18 : 10:02:37
quote:
getdate(),Nieuw,1


this aren't single quote '. It is `. Should use single quote to enclose the string


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

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-18 : 10:03:30
replace your code with this and try

INSERT INTO svf.dbo.KBODossier(KeyID, KeyidHoofd, DossType, IngaveDatum, Status, StatusID, StatusDatum, Medewerker,
PersType) VALUES (@KeyID,@Keyidhoofd, @DossType, getdate(),'Nieuw',1,getdate(),@MDWNr, @PersoonType)



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

Go to Top of Page

Landie
Starting Member

8 Posts

Posted - 2008-08-18 : 10:08:13
That's the solution.

I copied the stored procedure from a word document and I thought I've checked every ' but it seems I forgot one.

thanks !

Go to Top of Page
   

- Advertisement -