Is it possible to use DB name as parameter in user-defined function?
For example I've tried to use concatenation but it doesn't work in this way:
create function fn_getEntityOwners (@dbName varchar, @entityId bigint)
returns table
as
return
select
OWNERS.USER_ID
from
@dbName + '.dbo.OWNERS' as OWNERS
where
OWNERS.ENTITY_ID = @entityId
UPDATE: I use sql server