Click here to Skip to main content
16,015,658 members
Home / Discussions / Database
   

Database

 
GeneralRe: Checking Details to Display Pin
pmarfleet21-Dec-07 22:25
pmarfleet21-Dec-07 22:25 
GeneralCheck box = Unchecked Pin
s3rro21-Dec-07 8:00
s3rro21-Dec-07 8:00 
GeneralRe: Check box = Unchecked Pin
pmarfleet21-Dec-07 9:07
pmarfleet21-Dec-07 9:07 
GeneralRe: Check box = Unchecked Pin
Dave Kreskowiak21-Dec-07 9:51
mveDave Kreskowiak21-Dec-07 9:51 
GeneralRe: Check box = Unchecked Pin
GuyThiebaut23-Dec-07 10:44
professionalGuyThiebaut23-Dec-07 10:44 
GeneralDeleteing From Table A When Records Not Found in Table B Pin
gunner_uk200021-Dec-07 3:26
gunner_uk200021-Dec-07 3:26 
GeneralRe: Deleteing From Table A When Records Not Found in Table B Pin
Michael Potter21-Dec-07 4:24
Michael Potter21-Dec-07 4:24 
QuestionInserting bulk data to SQL DB (SQL 2000) [modified] Pin
Daminda21-Dec-07 1:51
Daminda21-Dec-07 1:51 
I am generating bulk invoices using front end and when I try to insert it to the data base it takes hours it’s unacceptable.

This is how I am doing the task
Get relevant Cx accounts to data tables
Generates Invoice header and detail records and store those records on Invoice Header and Detail Data tables

Loop the invoice header data table and Insert recodes using Strode procedure.
Loop the invoice detail data table and Insert recodes using Strode procedure.

To generate for 200000 invoices it takes more than 24 Hrs.

How can I improve the performance?

Please refer the code.


//Inserting the Invoice Header records
foreach(DataRow InvHDR in DS_BillData.Tables["InvoiceHeaderInformation"].Rows)
{

SqlParameter[] para =new SqlParameter[14];
para[0]=new SqlParameter("@GUAccountID",InvHDR["GUAccountID"]);
para[1]=new SqlParameter("@GUInvID",InvHDR["GUInvoiceID"]);
para[2]=new SqlParameter("@InvoiceNo",InvHDR["InvoiceNo"]);
para[3]=new SqlParameter("@InvoiceDate",StartDate);
para[4]=new SqlParameter("@DueDate",DueDate);
para[5]=new SqlParameter("@BatchNo",BatchID);
para[6]=new SqlParameter("@GUStatmentID",InvHDR["GUInvoiceID"]);
para[7]=new SqlParameter("@BatchSNCount",BatchSNCount);
para[8]=new SqlParameter("@PAYMENTRECIVED",InvHDR["PAYMENTRECIVED"]);
para[9]=new SqlParameter("@SubTotal",InvHDR["SubTotal"]);
para[10]=new SqlParameter("@InvoiceAmount",InvHDR["InvoiceAmount"]);
para[11]=new SqlParameter("@VAT",InvHDR["VAT"]);
para[12]=new SqlParameter("@OtherTax",InvHDR["OtherTax"]);
para[13]=new SqlParameter("@StatmentNo",InvHDR["InvoiceNo"]);
//para[13]=new SqlParameter("@WaveOFF","Y");

callSp("BillingInvoiceCreation_forFront",para);

}

Stored Procedure---

Procedure BillingInvoiceCreation_forFront
(
@GUAccountID as nvarchar(30),
@GUInvID as nvarchar(30),
@InvoiceNo as numeric,
@InvoiceDate as datetime,
@DueDate as datetime,
@BatchNo as Decimal,
@GUStatmentID as nvarchar(30),
@StatmentNo as numeric,
@BatchSNCount as decimal,
@PAYMENTRECIVED as decimal(9,2),
@SubTotal as decimal(9,2),
@InvoiceAmount as decimal(9,2),
@VAT as decimal(9,2),
@OtherTax as decimal(9,2)

)
as
BEGIN

Declare @PrintDescription as nvarchar(100)
Declare @GUItemID as nvarchar(30)
Declare @PaymentAmt as decimal(9,2)
Declare @DueAmount as decimal(9,2)
Declare @CreditNoteAmount as decimal(9,2)
Declare @BFAmount as decimal(9,2)





INSERT INTO B_BillingInvoiceHeader(StatementNo, GUStatementID, GUInvID,
CompanyID, LocationID, BranchID, DeptID, InvoiceNo,
InvoiceDate, DueDate, Status, GUAccountID, ManualInvoice,
BatchNo, InvoiceType,BatchSNCount,BillingYear,BillingMonth,SubTotal,InvoiceAmount,VAT,OtherTax)
VALUES(@StatmentNo, @GUStatmentID, @GUInvID,
1, 1, 1, 1, @InvoiceNo,
@InvoiceDate, @DueDate, 'New', @GUAccountID, 'N',
@BatchNo, 'Batch',@BatchSNCount,year(@InvoiceDate),month(@InvoiceDate),@SubTotal,@InvoiceAmount,@VAT,@OtherTax)





SELECT @BFAmount=isnull(SUM(InvoiceAmount - PaidAmount),0)
FROM B_BillingInvoiceHeader
WHERE (GUAccountID = @GUAccountID) AND (PaymentCompleted = N'N') AND BatchNo<@BatchNo


/*_________________ Add Sanka ______________________*/







exec BillingCustomerAdvances @GUInvID


--- Late Invoice Delocate-----------------------------------------------------------------<<(*_*)>>-----

SELECT @PaymentAmt = PaymentReceve From B_CustomerPaymentRec Where GUAccountID=@GUAccountID And BatchNo=@BatchNo

SELECT @CreditNoteAmount=isnull(SUM(Amount) ,0)
FROM B_CreditNote
WHERE (Status='APPROVED') And (Completed ='N') AND (GUAccountID = @GUAccountID)



INSERT INTO B_MonthlyOpenningBalance
(GuAccountID, BatchNo, OppenningBalance, ClosingBalance, CreditNote, AdvanceBalance, UtilizedCredits)
VALUES (@GuAccountID, @BatchNo, @BFAmount, @BFAmount+@InvoiceAmount, @CreditNoteAmount, 0, 0)


INSERT INTO B_MonthlyBF
(CompanyID, LocationID, BranchID, DeptID, BatchNo, BFAmount, GUAccountID)
VALUES (1, 1, 1, 1, @BatchNo, @BFAmount, @GUAccountID)


Update B_CreditNote Set Completed ='Y' WHERE (Status='APPROVED') And (Completed ='N') AND (GUAccountID = @GUAccountID)




END

------

Thanks for the help i am working on DTS update method con any one give me a direction or small sample code kind of a thing?

Regards,
Daminda.
modified on Friday, December 21, 2007 9:30:11 AM

GeneralRe: Inserting bulk data to SQL DB (SQL 2000) Pin
pmarfleet21-Dec-07 2:23
pmarfleet21-Dec-07 2:23 
GeneralRe: Inserting bulk data to SQL DB (SQL 2000) Pin
Paddy Boyd21-Dec-07 2:27
Paddy Boyd21-Dec-07 2:27 
GeneralCustom Auto Generated ID Pin
xavier198821-Dec-07 0:58
xavier198821-Dec-07 0:58 
GeneralRe: Custom Auto Generated ID Pin
pmarfleet21-Dec-07 2:21
pmarfleet21-Dec-07 2:21 
GeneralDatabas connection with java script Pin
rajesh4u20-Dec-07 22:48
rajesh4u20-Dec-07 22:48 
GeneralRe: Databas connection with java script Pin
Colin Angus Mackay21-Dec-07 0:12
Colin Angus Mackay21-Dec-07 0:12 
GeneralRe: Databas connection with java script Pin
NetBot22-Dec-07 18:26
NetBot22-Dec-07 18:26 
QuestionHow to avoid the alphabetic order of the columns returned when selected from a SQL linked server. Pin
kalam20-Dec-07 22:34
kalam20-Dec-07 22:34 
AnswerRe: How to avoid the alphabetic order of the columns returned when selected from a SQL linked server. Pin
Paddy Boyd21-Dec-07 1:03
Paddy Boyd21-Dec-07 1:03 
QuestionSql Server Login Pin
cbkulathunge20-Dec-07 20:05
cbkulathunge20-Dec-07 20:05 
GeneralRe: Sql Server Login Pin
Paul Conrad22-Dec-07 7:05
professionalPaul Conrad22-Dec-07 7:05 
QuestionNeed Query for Searching Name from database. Pin
mithun narayanan20-Dec-07 19:20
mithun narayanan20-Dec-07 19:20 
GeneralRe: Need Query for Searching Name from database. Pin
That's Aragon20-Dec-07 19:31
That's Aragon20-Dec-07 19:31 
GeneralRe: Need Query for Searching Name from database. Pin
mithun narayanan20-Dec-07 20:04
mithun narayanan20-Dec-07 20:04 
GeneralRe: Need Query for Searching Name from database. Pin
mithun narayanan20-Dec-07 20:50
mithun narayanan20-Dec-07 20:50 
GeneralDate Pin
trilokharry20-Dec-07 17:49
trilokharry20-Dec-07 17:49 
GeneralRe: Date Pin
That's Aragon20-Dec-07 19:24
That's Aragon20-Dec-07 19:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.