There is a task - depending on the value of the parameter passed to the table function, to make a select from one or from another table.

if (@param = 1) select * from dbo1 if(@param = 2) select * from dbo2 

I'm trying to do with if or case in sql server, but these statements need to write select inside a condition, and in my condition only the parameter is passed. How can I solve the problem?

  • four
    select * from dbo1 where @param = 1 union all select * from dbo2 where @param = 2 - Akina

0