MS-SQL2000
I am attempting to access a different database from a database on the same server. No matter what combination I use I am getting invalid columns etc. I am new at this and it is probably just some simple syntax I am missing.
Also this is test code. Once this code goes live it will be going cross servers. What extra code would I have to add in order to accomplish this.
Thanks so much for your help.
Code:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.VIEW_Phy_count_NEW
AS
SELECT TOP 100 PERCENT
CAST(PRODMSTR.PRODUCT AS CHAR (31)) AS prodmstr_product,
isnull(BINLOCAT.PRODUCT,PRODMSTR.PRODUCT) AS phy_Product,
isnull(SUM(BINLOCAT.QUANTITY * BINLOCAT.PACKSIZE),0) AS phy_Total_Pcs
FROM databasename.dbo.BINLOCAT RIGHT OUTER JOIN
databasename.dbo.PRODMSTR ON databasename.dbo.BINLOCAT.PRODUCT = databasename.dbo.PRODMSTR.PRODUCT
GROUP BY BINLOCAT.PRODUCT, PRODMSTR.PRODUCT
ORDER BY PRODMSTR.PRODUCT
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO