Sunday, February 19, 2012

Analyzer 2000 using 2005 database gives error

I am using Query Analyzer 2000 and pointing at a 2005 database. I keep
getting an error that I think it related to some code that is selecting data
into a temp table. The procedure runs perfect on a 2000 database.
here is the message
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData
(CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
Connection Broken
Any ideas?
Thank you
RichardAnd the procedure? Can we see it?
ML
http://milambda.blogspot.com/|||CREATE PROCEDURE arLedgerListingGenAP
@.ProcMode CHOICE = NULL, -- 'R'- Report Mode, ' ' or
NULL - Customer Care Mode
@.CustomerKey SMARTKEY,
@.StartDate DATETIME = NULL,
@.EndDate DATETIME = NULL,
@.cStartDate VARCHAR(40),
@.cEndDate VARCHAR(40),
@.gsUserLanguage LANG
AS
SET NOCOUNT ON
SET ANSI_NULLS OFF
DECLARE @.BeginingBalance AMOUNT2DEC,
@.EndingBalance AMOUNT2DEC
IF @.StartDate IS NULL OR LTRIM(RTRIM(@.cStartDate)) = ''
SELECT @.StartDate = "1900-01-01 00:00:00"
IF @.EndDate IS NULL OR LTRIM(RTRIM(@.cEndDate)) = ''
SELECT @.EndDate = CAST(CAST(YEAR(@.EndDate) as varchar) + CASE
WHEN
LEN(MONTH(@.EndDate)) = 1
THEN
'0' + CAST(MONTH(@.EndDate) AS varchar)
ELSE
CAST(MONTH(@.EndDate) AS varchar)
END + CASE
WHEN LEN(DAY(@.EndDate)) = 1
THEN '0' + CAST(DAY(@.EndDate) AS varchar)
ELSE CAST(DAY(@.EndDate) AS varchar)
END
+ ' 23:59:59' AS datetime)
IF @.cStartDate IS NOT NULL AND LTRIM(RTRIM(@.cStartDate)) <> ''
SELECT @.StartDate = @.cStartDate
IF @.cEndDate IS NOT NULL AND LTRIM(RTRIM(@.cEndDate)) <> ''
SELECT @.EndDate = CAST(CAST(YEAR(@.cEndDate) as varchar) + CASE
WHEN
LEN(MONTH(@.cEndDate)) = 1
THEN
'0' + CAST(MONTH(@.cEndDate) AS varchar)
ELSE
CAST(MONTH(@.cEndDate) AS varchar)
END + CASE
WHEN LEN(DAY(@.cEndDate)) = 1
THEN '0' + CAST(DAY(@.cEndDate) AS varchar)
ELSE CAST(DAY(@.cEndDate) AS varchar)
END
+ ' 23:59:59' AS datetime)
-- The temp tables used in the Ledger Listind Stored procedures.
-- i.e. arLedgerListingGenAP.sql.
CREATE TABLE #Activity
(ActivityKey SMARTKEY IDENTITY(1,1),
ActivityDate DATETIME,
Amount AMOUNT2DEC NULL,
Discount AMOUNT2DEC NULL,
InvoiceNo INVOICENO NULL,
ContractKey SMARTKEY NULL,
CreditInvoiceNo INVOICENO NULL,
TranType VARCHAR(8) NULL,
ShortDesc CHAR(6) NULL,
ActDesc MAXCHAR NULL,
TransDescription MAXCHAR NULL,
InvoiceTotal AMOUNT2DEC NULL,
InvoiceBalance AMOUNT2DEC NULL,
AccountBalance AMOUNT2DEC NULL,
EmployeeCode CHAR(3) NULL,
PaymentReference DESCRIPTION NULL,
RecordType CHAR(5) NULL,
Target INVOICENO NULL,
TransactionGroupNo INTEGER NULL,
TransactionType VARCHAR(40) NULL,
AmtAffectingBal AMOUNT2DEC NULL,
PaymentApplicationKey SMARTKEY NULL,
InvoiceType CHOICE NULL,
ReversalReference CHOICE NULL,
DatePaid DATETIME NULL,
InvoiceTerms DESCRIPTION NULL,
TermsCode CHAR(3) NULL,
DueDate DATETIME NULL,
PastDueDays INTEGER NULL,
ForeColor INTEGER NULL,
CustomerKey SMARTKEY,
OwnerKey SMARTKEY NULL,
PaymentOrInvoice CHAR(1) NULL,
InvoiceDate DATEONLY NULL,
SortinvoiceNo INVOICENO NULL,
TranFrom CHOICE NULL)
CREATE TABLE #TempActivity (ActivityKey SMARTKEY,
InvoiceNo INVOICENO,
TransactionType VARCHAR(40),
TrxCnt INTEGER,
TransDescription MAXCHAR)
/* CreditInvoiceNo INVOICENO,
Amount AMOUNT2DEC,
Total AMOUNT2DEC,
AppliedCredits AMOUNT2DEC,
CreationDate DATETIME,*/
-- Find all Invoice Transaction for the customer. We have to go to the line
item to find out what was done, Refunds, Returns, etc.
-- Get also the pending credits and their Status.
/*
INSERT INTO #TempActivity EXEC arLedgerListingGen1AP
@.CustomerKey = @.CustomerKey,
@.StartDate = @.StartDate,
@.EndDate = @.EndDate,
@.gsUserLanguage = @.gsUserLanguage
*/
-- Store all Transaction for the customer in a temp table.
INSERT INTO #Activity EXEC arLedgerListingGen2AP
@.CustomerKey = @.CustomerKey,
@.StartDate = @.StartDate,
@.EndDate = @.EndDate,
@.gsUserLanguage = @.gsUserLanguage
--IF EXISTS (SELECT * FROM #Activity WHERE ShortDesc LIKE '%MT' OR
ShortDesc = 'DM')
BEGIN
EXEC arLedgerListingGen1AP
@.CustomerKey = @.CustomerKey,
@.StartDate = @.StartDate,
@.EndDate = @.EndDate,
@.gsUserLanguage = @.gsUserLanguage
UPDATE X
SET TransactionType = Y.TransactionType,
TransDescription = Y.TransDescription,
ShortDesc = LTRIM(RTRIM(ShortDesc)) + 'MT'
FROM #Activity X
JOIN #TempActivity Y ON X.InvoiceNo = Y.InvoiceNo
END
EXEC arLedgerListGetBegBalGenAP @.CustomerKey, @.StartDate,
@.BeginingBalance OUTPUT
IF @.BeginingBalance IS NULL
SELECT @.BeginingBalance = 0
EXEC arLedgerListGetEndBalGenAP @.CustomerKey, @.EndDate, @.EndingBalance
OUTPUT
IF @.EndingBalance IS NULL
SELECT @.EndingBalance = 0
-- Get the Customerkey, RecordType and Contract key of the record that was
transferred IN/OUT, get running balance per Account and
-- per Invoice and Update Balances.
SELECT a.ActivityKey, a.ActivityDate, a.Amount, a.Discount, a.InvoiceNo,
a.ContractKey, a.CreditInvoiceNo,
a.TranType, ShortDesc = LEFT(a.ShortDesc,5), a.ActDesc,
a.TransDescription, a.InvoiceTotal,
InvoiceBalance = CASE
WHEN a.InvoiceNo NOT IN ('CREDIT',
'ACCCRD', 'ACCDEP', 'SECDEP','PREPAY')
THEN a.AmtAffectingBal + (SELECT
ISNULL(SUM(c.AmtAffectingBal), 0.00)
FROM
#Activity c
WHERE
c.ActivityKey < a.ActivityKey
AND
a.InvoiceNo = c.InvoiceNo)
ELSE 0.00
END,
AccountBalance = a.AmtAffectingBal + @.BeginingBalance + (SELECT
ISNULL(SUM(c.AmtAffectingBal),0.00)
FROM
#Activity c
WHERE
c.ActivityKey < a.ActivityKey),
a.EmployeeCode, a.PaymentReference, a.RecordType, a.Target,
a.TransactionGroupNo,
a.TransactionType, a.AmtAffectingBal, a.PaymentApplicationKey,
a.InvoiceType, a.ReversalReference,
a.DatePaid, a.InvoiceTerms, a.TermsCode, a.DueDate,
a.PastDueDays, a.ForeColor, a.CustomerKey, a.OwnerKey,
TransferCustomerKey = b.CustomerKey, TransferRecordType =
b.RecordType, TransferContractKey = b.ContractKey,
a.PaymentOrInvoice, a.InvoiceDate, a.SortinvoiceNo, a.TranFrom
INTO #Activity2
FROM #Activity a
LEFT JOIN arPaymentApplications b ON
a.TransactionGroupNo = b.TransactionGroupNo
AND
LEFT(a.RecordType, 1) = 'X'
--This record contains
the sum of all PREPAY adjustments for all customers
AND a.RecordType <>
'XIADP'
--XOADP is a Transfer
Out of Access Deposit for PREPAY
--In this case the
CustomerKey's must match.
AND a.CustomerKey =
CASE
WHEN a.RecordType = 'XOADP'
THEN a.CustomerKey
END
--Else any other X
RecordTypes are transfers of Security Deposits
--The CustomerKey's do
not match here because we are picking up who
--the moneies are
transfered to.
AND a.CustomerKey <>
CASE
WHEN a.RecordType <> 'XOADP'
THEN b.CustomerKey
END
-- get the Descriptions.
IF @.ProcMode IS NULL OR @.ProcMode = ' '
BEGIN
EXEC arLedgerListingGen3AP
@.BeginingBalance = @.BeginingBalance,
@.EndingBalance = @.EndingBalance,
@.gsUserLanguage = @.gsUserLanguage
END
ELSE
BEGIN
EXEC arLedgerListingGen4AP
@.BeginingBalance = @.BeginingBalance,
@.EndingBalance = @.EndingBalance,
@.gsUserLanguage = @.gsUserLanguage
END
GO
"ML" <ML@.discussions.microsoft.com> wrote in message
news:8899258C-9E33-4876-B54F-408943B42727@.microsoft.com...
> And the procedure? Can we see it?
>
> ML
> --
> http://milambda.blogspot.com/|||After going through the code there's one issue that stands out - your
INSERT...EXECUTE statements lack column declarations. Try fixing that, e.g.
insert <table>
(
<column list>
)
exec <procedure> <parameter list>
Make certain that the columns in the INSERT statement match the columns in
the result set of the procedure.
ML
http://milambda.blogspot.com/

No comments:

Post a Comment