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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-04-22 : 22:04:27
|
simon writes "I was wondering if you can have nested fetch statements.
I have 2 tables with which to create a ledger code. Table 1 has 4 accounts and table 2 has 50 ledger entities.
I want the fetch statement to grab the first row of table 1, assign it to a variable then grab the first row of table 2 and assign it to a variable. Then a statement will combine the 2 variables and add them to another table to create a ledger code (in the format entity-account).
Then I want to fetch the next row in Table 2 while still at the first row of table 1 then combine the 2 variables to add them to the ledger code table.
Thus I want to go through each row in table 2 and combine with the first row of table 1 until the end of table 2 is reached. Then I want to fetch the second row of table 1 and go through each row in table 2 to combine the variables and add to the ledger code table.
Can this be done using the cursor method?
If not how can I achieve this using SQL?" |
|
|
|
|
|