August 12, 2010 at 4:41 am
Aspg (8/12/2010)
HI ,While updating this data , the update is going in endless loop .
It doesnt found the rownt-1 row when rowcnt is 1
1-1 = 0
Endless loop in set-base query? Cool :-D, but SQL doesn't work like that untill you write a LOOP (using CURSOR and/or WHILE or GOTO things). I guess you just have very big table and it takes time...
Anyway, can you explain your sample:
i WANT DATA AS
code Stardate Enddate
---- ---------- ----------
1 2004-01-01 2004-31-12
2 2005-01-01 2003-31-12
3 2004-01-01 2004-31-12
3 2005-01-01 2003-31-12
4 2004-01-01 2004-31-12
4 2005-01-01 NULL
PREVIOUS DAY OF STARTDATE OF CODE 2 SHOULD BE ENDDATE OF CODE 1
How on earth the End date for CODE 2, Stardate 2005-01-01 and
CODE 3 Startdate 2005-01-01 is set to 2003-31-12?
But Enddate for CODE 4 Startdate 2005-01-01 is left as NULL
What is the rule?
Are you sure your "i WANT" is correct?
August 13, 2010 at 9:56 am
Sorry for the late reply and some absurd data.
I was posting these posts while at work and gave you the wrong data . Anyways , just consider the dates as it is for now . I have more than million records in the table . I am already using a temp table for row id .Hence i have to update twice .For this i am using a while loop . But for temp table update only it is taking too long a time . Maybe i am missing a trick .
Can anybody tell me how to do this update using loop ,or cursor or anything else.
August 16, 2010 at 3:05 am
Aspg (8/13/2010)
...I was posting these posts while at work and gave you the wrong data
...
Can anybody tell me how to do this update using loop ,or cursor or anything else.
You might be surprised to know that most of people who helps you here are also do it "while at work" - their work.
Your call for help has so limitted details that everyone here need to waste a lot of their time trying to guess what you want.
I suggest you again check the article by Jeff Moden about forum etiquette (link provided in the bottom of my signature). Post your question with required DDL and sample data, clearly present expected results, explain business rules wherever applicable.
Please - do the above! I guarantee that you will have helpfull anwsers very quickly.
Good Luck!
Viewing 3 posts - 16 through 17 (of 17 total)
You must be logged in to reply to this topic. Login to reply