Loop through each record in table - Execute an SP for each record, insert results of SP into TEMP table.
I'm new to "looping" in MS SQL Server 2K and I have this question:
How can I loop through a database table, for each record in the table I need to execute a stored procedure and update a temporary table based on the SP results? I know how to do everything but the loop..
Here's an example:
Customer table has 100 records. Customer_Id is the PK.
I have a stored procedure that returns an integer when I give it a customer_id.
I can do: exec sp_MyCount 23
The SP will return an the customer ID & an integer (the value is 4, in this case for customer # 23)