Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

result pull

Status
Not open for further replies.

dbsql

IS-IT--Management
Mar 29, 2007
19
US
hi i have view that have all the columns selected and have stored procedure that give calculated amount.

how can i get total result combine with all the result with both view and column.,

is it advisable to create cursor!!!

declare @id bigint

DECLARE Employee_Cursor CURSOR FOR
SELECT testid
FROM testview


OPEN Employee_Cursor;

FETCH NEXT FROM Employee_Cursor;
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH next FROM Employee_Cursor
into @id

while @@fetch_status = 0
begin
exec testproc @testid= @id
FETCH next FROM Employee_Cursor
into @servicekey
END

end
CLOSE Employee_Cursor;
DEALLOCATE Employee_Cursor;

 
It's probably advisable to create a new SP that aggregates the data. And don't use a cursor; dump results to a temp table or table variable and work with that.

If you must work with what you have, create a table variable that accepts the data from the SP call. INSERT the results of each call to the temp/variable table, and after you're done, join the view with the temp table.

Hopefully some of the gurus will be by to expound but my head hurts from being on the support desk and I'm headed out the door. Now.
 
but that proc can process one testid at a time.

exec testproc @id = '1234'

Thanks
 
if it try do join it give me following error
The multi-part identifier "t.testid" could not be bound.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top