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 |
|
wotrac
Yak Posting Veteran
98 Posts |
Posted - 2005-04-17 : 05:44:58
|
| Is it possible to create a view using a cursor? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-04-17 : 07:57:20
|
| No, and why would you want to? |
 |
|
|
wotrac
Yak Posting Veteran
98 Posts |
Posted - 2005-04-17 : 09:48:50
|
| I thought I might be able to resolve my problem by using a cursor, but wanted the resulting data to be available in a view, as the underlying data is changing constantly.If I explain the problem, could you suggest a better way of achieving the desired result.I have a table of stock assemblies, as below.I already know which code is at level one, but need to identify the levels of the other components.PRIMARY PARTCODE STOCK_CODE LEVEL1 acode1 stkcode1 LvL12 acode2 stkcode1 LvL13 acode1 stkcode2 LvL14 acode3 stkcode2 LvL15 bcode1 acode1 6 bcode2 acode1 7 ccode1 bcode1 8 ccode2 bcode2 9 dcode1 ccode1 If we take stkcode1 as the top levelThe corresponding hierarchy will bestcode1.......acode1.............bcode1...................ccode1.............bcode2.......acode2etc etcWhat I want to achieve is the followingLEVEL_1 Level_2 Level_3 Level_4stkcode1 acode1 bcode1 ccode1stkcode1 acode2 Null NullCould you suggest a quicker way of achieving this result |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-04-17 : 09:49:59
|
| See if this helps:http://www.sqlteam.com/item.asp?ItemID=8866 |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-04-17 : 13:04:34
|
| and http://www.mindsdoor.net/SQLTsql/RetrieveTreeHierarchy.htmlThe table used to produce the results has the full path as a work column.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|