Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Can It be done with SQL command ?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-05-05 : 15:08:37
Prabir writes "In a table 'A', I have records as follows:

ID Entry -date Withdraw-date

000001 08/18/2003 08/19/2003

000001 08/18/2003 11/04/2003

000001 08/19/2003 11/04/2003

000001 11/25/2003 12/01/2003

000001 11/25/2003 01/05/2004

000001 01/05/2004

000009 08/18/2003 02/05/2004

000009 10/03/2003 02/05/2004


Now, I want to check "Entry-date" with Prior "withdraw-date".
If Entry-date < Prior "withdraw-date" then I want to move
Prior "withdraw-date" to current "Entry-date".


Say for example, lets consider first 2 rows.
On row 2 , we have 08/18/2003 as entry date.
On row 1 , we have 08/19/2003 as prior Withdraw-date.
As Row 2 Entry date < Row 1 Withdraw-date, I want to move
08/19/2003 as row 2's Entry date and so on...



Can it be done with a single SQL or I need to create a cursor to do it.



Please help me.

Thank You

Prabir"

gpl
Posting Yak Master

195 Posts

Posted - 2004-05-05 : 17:01:28
Prabir
I think this article might point you in the right direction
http://www.sqlteam.com/item.asp?ItemID=12654
Graham
Go to Top of Page
   

- Advertisement -