Union Statements and User-Defined Functions

  • I have a question....probably a dumb one, but

    Is it possible to call user defined functions within unions

    for example:

    select 1, 2 from x

    union

    exec dbo.fnc_function1()

    ?

    Thanks,

    Michael

  • Functions don't get used with that particular syntax which is probably why you're having trouble. EXEC is for a stored procedure.

    Try -

    select 1, 2 from x

    union

    Select [3],[4] from dbo.fnc_function1()

    Keep in mind all of the usual rules about union (same columns, in the same order with the same types) applies here.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Thanks!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply