0

手順では、以下のようなステートメントがあります

declare @mnth int
select @mnth=month(cast('08/12/2013' as datetime))

if( @mnth<7)
begin

--some statements

end
else
begin

--some other statements

end

エラーが発生しています

キーワード「else」付近の構文が正しくありません。

何が悪いのか理解できません。助けてください

4

5 に答える 5

0

BEGINENDblockの間にいくつかのステートメントが必要です。コメントは許可されていません。

declare @mnth int
    select @mnth=month(cast('08/12/2013' as datetime))

if( @mnth<7)
begin
 DECLARE @Dummy bit 

--some statements



end
else
begin
 DECLARE @Dummy2 bit 
--some other statements

end
于 2013-09-12T11:12:47.383 に答える
0

次のコードで試してください

declare @mnth int select @mnth=month(cast('08/12/2013' as datetime)) BEGIN if( @mnth<7) begin

PRINT 'IF'

end else begin PRINT 'else' end END

于 2013-09-12T18:40:12.250 に答える