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.
| Author |
Topic |
|
xpandre
Posting Yak Master
212 Posts |
Posted - 2002-01-31 : 10:16:51
|
| Hi guys,I have a table suchid refid1 02 03 14 35 36 47 18 19 710 1Now i want all subordinates for 3 ,...suchid refid3 14 35 36 4Can this be done via a single query?if not,has any1 implemented a fucntion or proc for this...i need it very urgent ..and i think i wont have enough time to write a stored proc now .Thank youSam |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-01-31 : 10:30:07
|
| Can anyone explain the anti-stored procedure sentiment going around today?http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=12515Have you looked at graz's articles on the threaded discussions?http://www.sqlteam.com/item.asp?ItemID=1353http://www.sqlteam.com/item.asp?ItemID=1602For what it's worth, with the structure you have you'll need to have some kind of loop to fully traverse the tree. If you need to do this from a specific node, then making it a stored procedure will be easy: just pass the parent node in and it will zip right through. |
 |
|
|
xpandre
Posting Yak Master
212 Posts |
Posted - 2002-01-31 : 10:53:02
|
| thanx for the reply...1 more questionHow do i retrive just 1 row in the above table...with no asc/desc conditions?Thank you Sam |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-01-31 : 11:23:07
|
| You can use TOP:SELECT TOP 1 * FROM myTableOr you can SET ROWCOUNT:SET ROWCOUNT 1SELECT * FROM myTableIf you use SET ROWCOUNT and you have a batch of commands, make sure you SET ROWCOUNT immediately before the SELECT statement. If you SET ROWCOUNT before an UPDATE or DELETE it will limit the number of rows affected by those operations. |
 |
|
|
|
|
|