misdevelopers
asked on
Read a Temp Table in a stored procedure
In sql server 2000.
I have a temp table in a stored procedure,
I want to read through the temp table and examine each column in each of the rows of that table.
How would I do that.
I also need to determine if the table is empty or not before I start reading it.
Thanks
Laurence
I have a temp table in a stored procedure,
I want to read through the temp table and examine each column in each of the rows of that table.
How would I do that.
I also need to determine if the table is empty or not before I start reading it.
Thanks
Laurence
ASKER
Yes, I want to reference it inside the proc.
But I don't want to just create a recordset from the temp table.
I want to read through the temp table and examine each row and each column in each row.
I want to pass back just a few values from the recordset as OUPUT parameters,
rather than having to pass back the recordset (that was created from the temp table).
This is called thousands of times, for a report.
Laurence
But I don't want to just create a recordset from the temp table.
I want to read through the temp table and examine each row and each column in each row.
I want to pass back just a few values from the recordset as OUPUT parameters,
rather than having to pass back the recordset (that was created from the temp table).
This is called thousands of times, for a report.
Laurence
>>But I don't want to just create a recordset from the temp table.<<
The big question is: Why are you doing this? This is the least efficient way of doing things using T-SQL. However if you insist look up DECLARE CURSOR in BOL.
The big question is: Why are you doing this? This is the least efficient way of doing things using T-SQL. However if you insist look up DECLARE CURSOR in BOL.
acperkins is right. Maybe you should try assigning the values required to variables using TSQL. That would be much faster. What would be the size of the temporary table? Is it necessary that you do it row-by-row and column-by-column? Maybe I can help if you ca explain what exactly you are looking for.
hi misdevelopers,
Read about table variables and functions inside books online may be that is what you are looking for.
Read about table variables and functions inside books online may be that is what you are looking for.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
select * from sMyProc.#TmpTable