views:

17

answers:

2
CREATE PROCEDURE csGorevDuzenle
 @duzenle int,
 @grup_ad varchar(30), 
 @islem_grubu varchar(30),
 @tamamlayan varchar(30),
 @kayit_zamani datetime,
 @sonuc_zamani varchar(30),
 @arayan varchar(30),
 @telefon varchar(20),
 @tanim varchar(1000),
 @durum varchar(15),
 @aciklama varchar(1000)
AS

  if @duzenle = 1 then
BEGIN
 UPDATE gorevler SET grup_ad = @islem_grubu, tamamlayan = @tamamlayan, sonuc_zamani = @sonuc_zamani, arayan = @arayan, telefon = @telefon, tanim = @tanim, durum = @durum, aciklama = @aciklama
 WHERE grup_ad = @grup_ad and kayit_zamani = @kayit_zamani 
END

  end if
GO

Msg 156, Level 15, State 1, Procedure csGorevDuzenle, Line 20 Incorrect syntax near the keyword 'then'. Msg 156, Level 15, State 1, Procedure csGorevDuzenle, Line 26 Incorrect syntax near the keyword 'if'.

+2  A: 

This is not correct SQL syntax for an IF statement:

if @duzenle = 1 then

change to:

IF ( @duzenle = 1 )
Oded
and here's the reference: http://msdn.microsoft.com/en-us/library/ms182717.aspx
Rup
thank you very much
+1  A: 

T-SQL doesn't require you to write THEN after the IF statement. Change it to the following and it will work:

if @duzenle = 1 
BEGIN
Paul Spangle
Not only does it not require it, but using it is a syntax error...
Oded
thank you very much

related questions