Answer the question
In order to leave comments, you need to log in
How to use other databases in a function?
There is a simple function that returns a table - SELECT
values by identifier, for example
CREATE FUNCTION dbo.func1 (@dbase varchar(max),@t1f1var int)
RETURNS @restbl
TABLE(t1f1 int,t1f2 int)
AS
BEGIN
insert into @restbl
select t1f1, t1f2
from (хочу сюда писать '[email protected]+')dbo.t1
where t1f1= @t1f1var
return;
END
Answer the question
In order to leave comments, you need to log in
Create a view with all databases like this:
CREATE VIEW [dbo].[View_All]
AS
SELECT 'Videoteq' AS BaseName, ID, LastName FROM Videoteq.dbo.Person
UNION
SELECT 'Phondex', ID, LastName FROM Phondex.dbo.Performer
GO
SELECT LastName
FROM View_All
WHERE (BaseName = 'Phondex') AND (ID = 512)
function is neededSo make a function with a request from the view.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question