September 15, 2004 at 6:07 am
Im a real newbie and amateur here so please forgive the basic question I ask
drop view [dbo].[dev_ch_invoicedaybook]
GO
GO
SET ANSI_NULLS ON
GO
AS
SELECT InvoiceLines.Nominal, InvoiceHead.JobNo, InvoiceHead.InvoiceNo, InvoiceHead.Datedb, MainJobDetails.Ref1, MainJobDetails.Ref3,
InvoiceHead.AccountName, InvoiceHead.IsCreditNote,
SUM(CASE WHEN InvoiceLines.Nominal = 'A200' THEN 0 ELSE ISNULL(((InvoiceHead.IsCreditNote - 1) * - 2 - 1) * (InvoiceLines.NettAmount), 0) END)
AS Nett, (CASE WHEN EXISTS
(SELECT *
FROM PurchaseOrderLines
WHERE PurchaseOrderLines.JobNo = InvoiceHead.JobNo AND PurchaseOrderLines.ProductCode IN ('out printwebk', 'out printb1j', 'out printb1k',
'out printb2j', 'out printb2k', 'out printb1qty', 'outwebperk', 'outwebjob', 'out printwebj')) THEN 1 ELSE 0 END) AS OutworkExists
FROM InvoiceHead INNER JOIN
InvoiceLines ON InvoiceLines.InvoiceNo = InvoiceHead.InvoiceNo AND isnull(InvoiceHead.JobNo, '') = isnull(InvoiceLines.JobNo, '') LEFT OUTER JOIN
MainJobDetails ON MainJobDetails.JobNo = InvoiceHead.JobNo
WHERE InvoiceLines.Nominal <> 'A200'
InvoiceHead.IsCreditNote, InvoiceLines.Nominal
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
(SELECT *
FROM PurchaseOrderLines
WHERE PurchaseOrderLines.JobNo = InvoiceHead.JobNo AND PurchaseOrderLines.ProductCode IN ('out printwebk', 'out printb1j', 'out printb1k',
'out printb2j', 'out printb2k', 'out printb1qty', 'outwebperk', 'outwebjob', 'out printwebj')) THEN 1 ELSE 0 END)
Incorrect syntax near the keyword 'AS'.
September 15, 2004 at 6:17 am
Can you please post the revised code that you have removed parts from so we can see where the syntax error is coming from?
Good Hunting!
AJ Ahrens
webmaster@kritter.net
September 15, 2004 at 6:41 am
thx for your help offer
Im now sorted......
Typical - you look at a problem for ages and cannot see wood for trees
then as soon as you ask for help- the answer hits you in the face
In my case - of the items I removed, I left behind a comma and a item line reference I didnt want to see
My new script works a treat
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[dev_ch_invoicedaybookmain]') and OBJECTPROPERTY(id,
N'IsView') = 1)
drop view [dbo].[dev_ch_invoicedaybookmain]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.dev_ch_invoicedaybookmain
AS
SELECT InvoiceLines.Nominal, InvoiceHead.JobNo, InvoiceHead.InvoiceNo, InvoiceHead.Datedb, MainJobDetails.Ref1,
MainJobDetails.Ref3,
InvoiceHead.AccountName, InvoiceHead.IsCreditNote,
SUM(CASE WHEN InvoiceLines.Nominal = 'A200' THEN 0 ELSE ISNULL(((InvoiceHead.IsCreditNote - 1) * - 2
- 1) * (InvoiceLines.NettAmount), 0) END)
AS Nett
GROUP BY InvoiceHead.JobNo, InvoiceHead.InvoiceNo, InvoiceHead.Datedb, MainJobDetails.Ref1, MainJobDetails.Ref3,
InvoiceHead.AccountName,
InvoiceHead.IsCreditNote, InvoiceLines.Nominal
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply