For starters, it would be helpful if you posted your code. Quite often SQL can be modified to process multiple values in a "Set-based" way. In other words, if you had a set of values to process, you could process them all simultaneously.
There are many ways to accomplish this. You could pass in a delimited string and then parse that in your proc. Lots of ideas on the implementation of this here
You could also pass in XML and "join" to the XML in your proc using APPLY
.
In SQL 2008+ you can use Table Valued Parameters
Because I don't know what exactly you're doing with the AreaID parameter, I don't know if I've answered your question so here is some more info.
If you want to run a stored procedure asynchronously, your best bet is Service Broker which will allow you to put a parameter in a queue and separate thread(s) will process the queue. SQL manages all the ordering, locking, retry, spawning/killing threads etc. It's a very robust system.
There is a comment on the question from a different user who seems to be connected to the OP concerning progress tracking. Here is a thought:
You have a "queue" table that contains a batchid and the areaID parameter and a status flag.
CREATE TABLE asynchQueue
(
RecNo INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
BatchID INT,
AreaID INT,
Status TINYINT
)
Your C# app inserts into the queue table with a unique batch id for your app and call (to group your requests)
You have a proc scheduled to run periodically like this:
CREATE PROC ProcessQueue
AS
BEGIN
SET XACT_ABORT ON
DECLARE @RecNo INT,
@AreaId INT
BEGIN TRAN
SELECT TOP 1 @RecNo = recNo,
@AreaID = areaId
FROM AsynchQueue WITH ROWLOCK, XLOCK
WHERE Status = 0
UPDATE AsynchQueue SET Status = 1 --Mark record as in progress
WHERE RecNo = @RecNo
COMMIT
EXEC YourProc @AreaId
UPDATE AsynchQueue SET Status = 2 -- Mark Record as complete
WHERE RecNo = @RecNo
END
Or the proc could contain a loop to process all records in the table. The proc could be scheduled or invoked on demand using sp_start_job as John Weldon suggested.
You could then query status as follows:
SELECT COUNT(NULLIF(Status, 0))/COUNT(*) as PctComplete --in progress or complete div by total
FROM AsynchQueue WITH NOLOCK
WHERE BatchID = @yourBatchId
That query will give you the percent complete of your batch.