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 |
|
lazydev
Starting Member
16 Posts |
Posted - 2008-04-17 : 18:30:55
|
| i want to store the output in out variable .Which gives multiple values.create procedure usp_test (@AccountID INT)asbeginDECLARE @getAccountID CURSOR SET @getAccountID = CURSOR FORSELECT Account_ID FROM Accounts OPEN @getAccountID FETCH NEXT FROM @getAccountID INTO @AccountIDWHILE @@FETCH_STATUS = 0 BEGIN PRINT @AccountID FETCH NEXT FROM @getAccountID INTO @AccountID END CLOSE @getAccountID DEALLOCATE @getAccountIDendi get nearly ten rows in the print statement how can i assign the output to a out variable where i get all ten rows.Any ideas or suggestions. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2008-04-17 : 18:43:35
|
| not sure what you mean. You want the resultset?Then use a temp table and don't use a cursor.create proc usp_testasinsert #Accountsselect Account_IDFROM Accounts gocreate table #Accounts (Account_ID int)exec usp_testselect * from #Accountsor do the insert in the calling codecreate proc usp_testasselect Account_IDFROM Accounts gocreate table #Accounts (Account_ID int)insert #Accountsexec usp_testselect * from #Accounts==========================================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. |
 |
|
|
|
|
|