I'm trying to create a view that is a join between two tables in two databases in the same SQL Server instance.
CREATE VIEW PartCostView AS SELECT ItemNmb, CSECO.dbo.MIITEM.descr, CostEach, LeadTimeDays FROM PartCost LEFT OUTER JOIN CSECO.dbo.MIITEM ON ltrim(rtrim(ItemNmb)) = ltrim(rtrim(CSECO.dbo.MIITEM.descr))
This query returns NULL for the descr field, without the left outer join it returns no rows. Doing a query in Query Analyzer is the same. If I perform the query in an external application through an ODBC driver it works correctly. ???
that means you dont have matching records in CSECO.dbo.MIITEM. are you sure relation you gave is correct? ltrim(rtrim(ItemNmb)) = ltrim(rtrim(CSECO.dbo.MIITEM.descr))
Absolutely sure. As I mentioned, if I issue the query in an external program through an ODBC driver the query works correctly (and doesn't require the ltrim-rtrim).