1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

user defien function throws an error

Discussion in 'SQL Server' started by ERUM, Oct 12, 2007.

  1. ERUM

    ERUM New Member

    Joined:
    Sep 26, 2007
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    CREATE FUNCTION dbo.myFunction1()
    AS
    BEGIN
    DECLARE @myInt INT
    SET @myInt = 1
    -- Function body goes here
    --RETURN @myInt
    END

    i write above udf which neither accepts nor return any value but it says

    Incorrect syntax near the keyword 'AS'.

    what is mistake i have made
     
  2. venkatesanj@hcl.in

    venkatesanj@hcl.in New Member

    Joined:
    Oct 19, 2007
    Messages:
    24
    Likes Received:
    1
    Trophy Points:
    0
    Just make a try with the below code sir,

    you should not use 'AS' keyword like Stored procedure


    CREATE FUNCTION dbo.myFunction1()
    returns int
    BEGIN
    DECLARE @myInt INT
    SET @myInt = 1
    -- Function body goes here
    RETURN @myInt
    END

    Regards,
    Venkatesan Prabu. J
     

Share This Page