I have a report which had a view attached to it which I have replaced with a stored proc (for efficiency... the view had a load of UNION ALLs but were pulling from the same tables so creating a temporary table and then doing the UNIONs is much faster)
I am now getting a "There are no fields in the File" error.
Having done a search for this it seems to be related to having no select statement that Crystal recognizes, but this is not the case here.
I have tried selecting the UNION stuff into a second temporary table and then selecting from there, but that gives me the same error.
Any ideas ?
I am now getting a "There are no fields in the File" error.
Having done a search for this it seems to be related to having no select statement that Crystal recognizes, but this is not the case here.
Code:
CREATE PROCEDURE RPT_Inventory_1
@Start_Date DATETIME,
@End_Date DATETIME
AS
SELECT @Start_Date = CONVERT(CHAR(10), @Start_Date, 101) + ' 00:00:00.000'
SELECT @End_Date = CONVERT(CHAR(10), @End_Date, 101) + ' 23:59:59.997'
SELECT
a.CLM_PHCode,
b.HPC_Intlzip,
a.CLM_DateRecd,
a.CLM_CreateDate,
c.CLD_AdjCode,
a.CLM_Net
INTO #Report_Data
FROM
DMG_Claim_Masters a (nolock) INNER JOIN
DMG_HP_Contracts b (nolock) ON a.CLM_HPCode = b.HPC_HPCode INNER JOIN
DMG_Claim_Details c (nolock) ON a.CLM_ClaimNo = CLD_ClaimNo
WHERE
a.CLM_DateRecd BETWEEN @Start_Date AND @End_Date
SELECT
'Paid' AS ClaimType,
CLM_PHCode,
HPC_Intlzip,
MONTH(CLM_DateRecd) AS ClaimMonth,
CLM_DateRecd,
CLM_CreateDate
FROM
#Report_Data
WHERE
CLD_AdjCode IS NULL
OR CLD_AdjCode IN (<list 1>)
UNION ALL
SELECT
'Contested/Denied',
CLM_PHCode,
HPC_Intlzip,
MONTH(CLM_DateRecd) AS ClaimMonth,
CLM_DateRecd,
CLM_CreateDate
FROM
#Report_Data
WHERE
CLD_AdjCode IN (<list 2>)
UNION ALL
SELECT
'Adjusted',
CLM_PHCode,
HPC_Intlzip,
MONTH(CLM_DateRecd) AS ClaimMonth,
CLM_DateRecd,
CLM_CreateDate
FROM
#Report_Data
WHERE
CLD_AdjCode IN (<list 3>)
UNION ALL
SELECT
'Forwarded',
CLM_PHCode,
HPC_Intlzip,
MONTH(CLM_DateRecd) AS ClaimMonth,
CLM_DateRecd,
CLM_CreateDate
FROM
#Report_Data
WHERE
CLD_AdjCode = 'FORW'
UNION ALL
SELECT
'Acknowledged 1',
CLM_PHCode,
HPC_Intlzip,
MONTH(CLM_DateRecd) AS ClaimMonth,
CLM_DateRecd,
CLM_CreateDate
FROM
#Report_Data
UNION ALL
SELECT
'Acknowledged 2',
CLM_PHCode,
HPC_Intlzip,
MONTH(CLM_DateRecd) AS ClaimMonth,
CLM_DateRecd,
CLM_CreateDate
FROM
#Report_Data
WHERE
CLD_AdjCode NOT IN (<list 4>)
AND((CLM_Net > 0)
OR (CLM_Net = 0
AND CLD_AdjCode <> '#C'))
UNION ALL
SELECT
'Input',
CLM_PHCode,
HPC_Intlzip,
MONTH(CLM_DateRecd) AS ClaimMonth,
CLM_DateRecd,
CLM_CreateDate
FROM
#Report_Data
I have tried selecting the UNION stuff into a second temporary table and then selecting from there, but that gives me the same error.
Any ideas ?