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)
 Recursive ???

Author  Topic 

sfunds
Starting Member

7 Posts

Posted - 2006-05-29 : 03:04:33
Hi
I have a table which is as follows

table namechanged(

new_name varchar(50),
old_name varchar(50),
date_changed datetime
)

I would like to write a query where in the input parameter is new_nameand date and I should get all its old_name and date_changed rows

eg
LNST LARSONTUBRO 2000-01-01
L&T LNST 2001-01-01
LT L&T 2004-01-01
IISCO BALAPUR 2000-01-01
ILSCO IISCO 2001-01-01
PISCO ILSCO 2002-01-01
SAIL PISCO 2003-01-01

so if i ask for LT and date 2004-01-01 first three rows
i ask for sail and date > 2003-01-01 last four rows
i ask for Pisco and date between (2002-01-01 and 2003-01-01) rows 4,5,6
Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-29 : 04:24:55
Read these
http://vyaskn.tripod.com/hierarchies_in_sql_server_databases.htm
http://www.nigelrivett.net/RetrieveTreeHierarchy.html
http://www.seventhnight.com/treestructs.asp

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -