I am writing a sql query to pull some data from one of our linked oracle servers.
The only problem with this query is with the two date add rows (with them removed the query runs) but i need their data.
I receive the below error: OLE DB provider "MSDAORA" for linked server "MAGINUS" returned message "ORA-00904: "DATEADD": invalid identifier
Could anyone prescribe a syntax for these?
Thanks in advance
Will
DECLARE @TSQL VARCHAR(8000)
,@CUSTOMER_ACCOUNT VARCHAR(20)
SELECT @TSQL1 = '
SELECT * FROM OPENQUERY(MAGINUS,''
SELECT
CM.CUSTOMER_ACCOUNT AS "CustomerAccount"
,CM.CONTACT_NAME AS "ContactName"
,CM.MEMBERSHIP_NUMBER AS "MembershipNumber"
,P.LONG_DESCRIPTION_1 AS "ProductDescription"
,DATEADD(SECOND, CM.MEMBERSHIP_START_DATE, "19700101") AS "MembershipStartDate"
,DATEADD(SECOND, CM.MEMBERSHIP_EXPIRY_DATE, "19700101") AS "MemberhrshipEndDate"
,SH.ORDER_VALUE AS "Price Paid"
FROM MAGINUS.CUSTOMER_MEMBERSHIP CM
INNER JOIN MAGINUS.PRODUCT P
ON CM.PRODUCT_CODE = P.PRODUCT_CODE
INNER JOIN MAGINUS.SALES_HEADER SH
ON CM.CUSTOMER_ACCOUNT = SH.CUSTOMER_ACCOUNT
AND CM.SALES_DOCUMENT_NUM = SH.SALES_DOCUMENT_NUM
WHERE CM.CUSTOMER_ACCOUNT = ''''' + @CUSTOMER_ACCOUNT + ''''''')'
EXEC (@TSQL1)