Is it possible to setup a view in Database A that references a table in Database B?
I'm getting the following error:
Cannot schema bind view 'dbo.AGView' because name 'dbB..AG2Table' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.
USE [dbA]
GO
IF EXISTS(SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[AGView]'))
DROP VIEW [dbo].[AGView]
GO
USE [dbA]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[AGView] WITH SCHEMABINDING AS
SELECT ag.Id AS [AGId], ag.Name AS [AGName]
FROM dbB..AG2Table agcag
JOIN dbB..AGTable ag on ag.Id = agcag.Id
GO