sqlsql-serversql-server-2005t-sql

One INSERT with UNIONS or multiple INSERTS?


I have a sql function that returns a table. The table is populated via 6 or so reasonably complex statements.

Is it better to UNION together these statement so there is only 1 insert or are these better kept separate?

Or does it make no difference whatsoever?


Solution

  • Within a User Defined Function, I don't see a reason to use one over the other. A UNION has the potential to be more constraining than separate statements...

    I'd like to see the details of the function, and it's use, because it's possible it might not be necessary at all.