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 |
|
amigosnw
Starting Member
1 Post |
Posted - 2002-09-06 : 13:59:11
|
| This script is only looping through the first iteration of the first cursor, but will iterate through the second successfully. Any suggestions?Here's the script:DECLARE @iCompanyId AS INTDECLARE @iIndividualId AS INTDECLARE @iSiteId AS INTSET @iSiteId = 1DECLARE com_Cursor CURSOR FOR SELECT iCompanyId FROM #tempCompanyOPEN com_Cursor FETCH NEXT FROM com_Cursor INTO @iCompanyId--WHILE @@FETCH_STATUS = 0 BEGIN DECLARE ind_Cursor CURSOR FOR SELECT iContactId FROM #tempContacts OPEN ind_Cursor FETCH NEXT FROM ind_Cursor INTO @iIndividualId BEGIN EXEC wbospsiContact @iSiteId, Null, @iIndividualId, @iCompanyId, 47, Null, 'RshInsert', Null, 1, 1, Null, 'RshInsert' FETCH NEXT FROM ind_Cursor INTO @iIndividualId END CLOSE ind_Cursor DEALLOCATE ind_CursorFETCH NEXT FROM com_Cursor INTO @iCompanyId END CLOSE com_CursorDEALLOCATE com_Cursor |
|
|
1fred
Posting Yak Master
158 Posts |
Posted - 2002-09-06 : 14:13:13
|
| can it be because you are not looping trought your second cursor, so when it comes to the fetch your variable @@fetch_status takes 1. Because there is only one variable for the 2 cursor, it is like a global variable. |
 |
|
|
|
|
|
|
|