26. September 2008 13:42
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW TESTVIEW
AS
SELECT
CONVERT(NVARCHAR,SalesHeader.[No_]) AS Belegnr,
CONVERT(NVARCHAR,SalesHeader.[No_]) AS VorgangNr,
CONVERT(NVARCHAR,SalesHeader.[Sell-to Customer No_]) AS VKDebNr,
CONVERT(NVARCHAR,SalesHeader.[Sell-to Customer Name]) AS VKDebName,
CONVERT(NVARCHAR,Cont.[Company No_]) AS VKInteressNR,
CONVERT(NVARCHAR,SalesHeader.[Bill-to Customer No_]) AS RGDebNr,
CONVERT(NVARCHAR,SalesHeader.[Bill-to Name]) AS RGDebName
FROM dbo.[MandantA$Sales Header] AS SalesHeader
WHERE (SalesHeader.[Document Type] = 1,
dbo.[Contact] AS Cont
WHERE Cont.[Debitorennr_] = SalesHeader.[Sell-to Customer No_]
26. September 2008 13:45
26. September 2008 14:16
any1 hat geschrieben:Hallo,
ich möchte einen SQL-View erstellen, leider klappt das nicht so, wie ich gerne möchte.
Der View soll auf 2 Tabellen zugreifen.
Sales Header und mit der Sell-to-Customer-No soll er aus der Kontakt-Tabelle die Unternehmensnummer holen:
- Code:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW TESTVIEW
AS
SELECT
CONVERT(NVARCHAR,SalesHeader.[No_]) AS Belegnr,
CONVERT(NVARCHAR,SalesHeader.[No_]) AS VorgangNr,
CONVERT(NVARCHAR,SalesHeader.[Sell-to Customer No_]) AS VKDebNr,
CONVERT(NVARCHAR,SalesHeader.[Sell-to Customer Name]) AS VKDebName,
CONVERT(NVARCHAR,Cont.[Company No_]) AS VKInteressNR,
CONVERT(NVARCHAR,SalesHeader.[Bill-to Customer No_]) AS RGDebNr,
CONVERT(NVARCHAR,SalesHeader.[Bill-to Name]) AS RGDebName
FROM dbo.[MandantA$Sales Header] AS SalesHeader
WHERE (SalesHeader.[Document Type] = 1,
dbo.[Contact] AS Cont
WHERE Cont.[Debitorennr_] = SalesHeader.[Sell-to Customer No_]
Der View ohne die Contact-Anteile funktioniert wunderbar.
Sobald ich allerdings die Tabelle Contact mit einbeziehe, bekomme einen ODBC-Timeout...
Was ist falsch/schlecht/verkehrt?
SELECT [ABC$Sales Header].No_, [ABC$Contact].Name
FROM [ABC$Sales Header] INNER JOIN
[ABC$Contact] ON [ABC$Sales Header].[Sell-to Contact No_] = [ABC$Contact].No_