• You don't have any variables in your code.

    You can check the CREATE FUNCTION syntax in here http://msdn.microsoft.com/es-es/library/ms186755%28v=sql.90%29.aspx

    CREATE FUNCTION dbo.Example_function_name

    (

    @Parameter1 int

    )

    RETURNS TABLE

    AS

    RETURN

    SELECT bb.level , 'Myvalue5' as'Table'

    From BaseTable bb

    Left Join dbo.a on (bb.col1 = a.col1)

    UNION

    SELECT bb.level , 'Myvalue4' as'Table'

    From BaseTable bb

    Left Join dbo.a on (bb.col1 = a.col1) ;

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2