Click here to Skip to main content
15,920,629 members
Home / Discussions / Database
   

Database

 
GeneralRe: CPU Process on Clinet/Server? Pin
LordCover15-Jun-08 1:55
LordCover15-Jun-08 1:55 
Questionhow i can roll back today transaction Pin
wasimsharp13-Jun-08 19:43
wasimsharp13-Jun-08 19:43 
AnswerRe: how i can roll back today transaction Pin
Ashfield15-Jun-08 21:08
Ashfield15-Jun-08 21:08 
AnswerRe: how i can roll back today transaction Pin
Alsvha16-Jun-08 2:11
Alsvha16-Jun-08 2:11 
QuestionProblem using FillSchema Pin
FerJones13-Jun-08 14:23
FerJones13-Jun-08 14:23 
QuestionStored Procedure not working with parameters as sort order Pin
Brendan Vogt13-Jun-08 2:22
Brendan Vogt13-Jun-08 2:22 
AnswerRe: Stored Procedure not working with parameters as sort order Pin
SomeGuyThatIsMe13-Jun-08 2:29
SomeGuyThatIsMe13-Jun-08 2:29 
AnswerRe: Stored Procedure not working with parameters as sort order Pin
Ashfield13-Jun-08 2:37
Ashfield13-Jun-08 2:37 
AnswerRe: Stored Procedure not working with parameters as sort order Pin
Alsvha13-Jun-08 3:03
Alsvha13-Jun-08 3:03 
GeneralRe: Stored Procedure not working with parameters as sort order Pin
Ashfield13-Jun-08 3:56
Ashfield13-Jun-08 3:56 
Questionproblem in creating sql reports in asp.net Pin
prakss13-Jun-08 1:51
prakss13-Jun-08 1:51 
QuestionSQL Query - If condition Pin
aaraaayen12-Jun-08 20:56
aaraaayen12-Jun-08 20:56 
AnswerRe: SQL Query - If condition Pin
Ashfield12-Jun-08 21:08
Ashfield12-Jun-08 21:08 
GeneralRe: SQL Query - If condition Pin
aaraaayen12-Jun-08 21:38
aaraaayen12-Jun-08 21:38 
GeneralRe: SQL Query - If condition Pin
Ashfield12-Jun-08 21:39
Ashfield12-Jun-08 21:39 
QuestionRestore backup from sql server 2005 to 2000 Pin
PrakashBhaskar12-Jun-08 19:56
PrakashBhaskar12-Jun-08 19:56 
AnswerRe: Restore backup from sql server 2005 to 2000 Pin
Parwej Ahamad12-Jun-08 20:48
professionalParwej Ahamad12-Jun-08 20:48 
AnswerRe: Restore backup from sql server 2005 to 2000 Pin
Mycroft Holmes12-Jun-08 20:49
professionalMycroft Holmes12-Jun-08 20:49 
QuestionError in Mail Triggering Pin
sabaMCA12-Jun-08 11:54
sabaMCA12-Jun-08 11:54 
AnswerRe: Error in Mail Triggering Pin
Parwej Ahamad12-Jun-08 17:43
professionalParwej Ahamad12-Jun-08 17:43 
QuestionSql cursor problem... Pin
tthellebuyck12-Jun-08 4:38
tthellebuyck12-Jun-08 4:38 
AnswerRe: Sql cursor problem... Pin
A Wong12-Jun-08 4:47
A Wong12-Jun-08 4:47 
GeneralRe: Sql cursor problem... Pin
tthellebuyck12-Jun-08 5:08
tthellebuyck12-Jun-08 5:08 
AnswerRe: Sql cursor problem... Pin
Mark J. Miller12-Jun-08 7:46
Mark J. Miller12-Jun-08 7:46 
I don't know your schema so consider this as psudocode, but this will be faster due to the fact that it isn't using a cursor (as suggested previously). Then, if possible, I would add datetime columns which you can use to compare the date your _CustomerUpdate table was changed with the date your CustTreeNodeAccountAssoc table was updated. This will prevent the need to retrieve all 600K+ records, that will also considerably speed things up and it will scale better as the number of records increases.

<br />
Declare @ARbal money,<br />
@CustTreeNodeID uniqueidentifier,<br />
@CustomerNumber varchar(50),<br />
@CustomerUpdateID int,<br />
@LYSales money,<br />
@LYTDSales money,<br />
@YTDgm money,<br />
@YTDSales money,<br />
@MTDSales money,<br />
@LMTDSales money<br />
<br />
Declare @t table<br />
(<br />
CustomerUpdateID int,<br />
CustomerNumber varchar(50),<br />
YTDSales money,<br />
LYSales money,<br />
ARBal money,<br />
LYTDSales money,<br />
MTDSales money,<br />
LMTDSales money<br />
)<br />
<br />
insert into @t(CustomerUpdateID, CustomerNumber,YTDSales, LYSales,ARBal, LYTDsales,MTDSales,LMTDSales)<br />
<br />
select CustomerUpdateID,<br />
CustomerNumber,<br />
YTDSales,<br />
LYSales,<br />
ARBal,<br />
LYTDSales,<br />
MTDSales,<br />
LMTDSales<br />
from _CustomerUpdate u <br />
<br />
where exists (select 1 from CustTreeNode c join CustTreeNodeaccountAssoc ca on ca.CustTreeNodeID = c.CustTreeNodeID and (u.LYTDSales != ca.LYTD or u.YTDSales != ca.YTD or u.MTDSales!= ca.MTD or u.LMTDSales !=ca.LMTD ))<br />
<br />
-- REPLACE YOUR CURSOR WITH THIS CODE BELOW (or something similar that better fits your logic)<br />
UPDATE A<br />
  YTD = T.YTDSales, <br />
  LYTD = T.LYSales,<br />
  Balance = T.ARBal<br />
FROM @t T<br />
INNER JOIN CustTreeNode N ON N.CustomerNumber = T.CustomerNumber<br />
INNER JOIN CustTreeNodeAccountAssoc A ON A.CustTreeNodeID = N.CustTreeNodeID<br />



Questiondata connection and path to be written once Pin
Member 429901311-Jun-08 23:44
Member 429901311-Jun-08 23:44 

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.