rocky_498 (9/19/2012)
I have a question,Here is my query,
SELECT SID FROM chartdDB
WHERE ADate = @ADate
AND SID NOT IN (SELECT SID FROM UPLOADRequest )
when i run this query sometime i get 1 SID or sometime more then One.
I have two question.
1) How i can set my Parameter to Previous day
Set @ADate = (If i run today @ADate should be Previous day) ?
2) Once i run this query
SELECT SID FROM chartdDB
WHERE ADate = @ADate
AND SID NOT IN (SELECT SID FROM UPLOADRequest )
THEN EXECUTE THIS STORE PROCEDURE
exec Save_Request @sid
, How i can create Cursor if i get more than one result this store proc run more than one time.
Please let me know if my question is not clear.
Thank You.
As has already been pointed out, you don't want to use a cursor to do this.
If I understand correctly, you would like to execute Save_Request for every SID value you return from
query 2)? You haven't provided any ddl or sample data so I can only make a suggestion which may or may not work in your case.
You can insert the output of query 2) to a table and supply it to the Save_Request Procedure via a Table Parameter and do the processing for all SIDs avoiding the need for the cursor and multiple calls to the Procedure.