sireesh sai
sireesh sai

Reputation: 13

Incorrect syntax near the keyword 'SET' and also giving me some warnings

Can anyone please help me out with the warnings in the below query

CREATE FUNCTION MyRound(@Operand Float,@Places INT) 
RETURNS Float
AS
BEGIN
    DECLARE @x Float;
    DECLARE @i INT;
    DECLARE @ix Float;

      SET @x = @Operand*Power(10,@Places);
      SET @i=@x;

      IF ((@i-@x) >= 0.5) 
      Begin                   
        SET @ix = 1;   
        End               
      ELSE
      Begin
        SET @ix = 0;  
        End               
      END ;     

      SET @x=@i+@ix;
      SET @x=@x/Power(10,@Places);

    RETURN @x;
END

I am getting 3 different warnings

  1. Create Function must be the only statement in the batch
  2. Must Declare Scalar Variable
  3. Incorrect syntax near End of File. Expecting CONVERSATION.

Upvotes: 0

Views: 1881

Answers (1)

DimaSUN
DimaSUN

Reputation: 921

See lines

  Begin
        SET @ix = 0;  
        End               
      END ;   

remove one not expected End

Upvotes: 1

Related Questions