rcl58
asked on
Changing Stored Procedure Execution Context
I have a stored procedure that my user accesses from MS VB.Net. At the end of the sproc1 I want to execute a different sproc2 but do the return so my user can continue. In other words, I do not want my user to wait for the completion of sproc2 to continue.
How can I do this?
How can I do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How do you start a job in the first procedure?
Thanks
Bob
Thanks
Bob
Hi Bob,
Use sp_add_job to create the job, use sp_add_jobstep to add a step that calls the procedure, sp_start_job to start the job you have just created.
specifying a @delete_level = ] delete_value with 3 means that when your job completes it will be deleted, ie cleaned up afterwards.
Values are
Value Description
0 Never (default)
1 On success
2 On failure
3 Always
HTH
David
Use sp_add_job to create the job, use sp_add_jobstep to add a step that calls the procedure, sp_start_job to start the job you have just created.
specifying a @delete_level = ] delete_value with 3 means that when your job completes it will be deleted, ie cleaned up afterwards.
Values are
Value Description
0 Never (default)
1 On success
2 On failure
3 Always
HTH
David
ASKER
Thanks David,
That will definitely do the trick. Unfortunately, I also need this to run on SQL Express and it doesn’t have the SQL Server Agent. Any other ideas?
Thanks again,
Bob
That will definitely do the trick. Unfortunately, I also need this to run on SQL Express and it doesn’t have the SQL Server Agent. Any other ideas?
Thanks again,
Bob
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
depending on your skill level...
create a script file containing what you want to execute
use the Shell/Process object to execute the script using a Command Line
sqlcmd -S (local) -d nss -U <user> -P <password> -i myscript.sql 2>> script.log
you can read the script.log later
p/s remove -U and -P if using NT authentication
create a script file containing what you want to execute
use the Shell/Process object to execute the script using a Command Line
sqlcmd -S (local) -d nss -U <user> -P <password> -i myscript.sql 2>> script.log
you can read the script.log later
p/s remove -U and -P if using NT authentication
ASKER
imitchie,
Thanks for your help. Is the Shell/Process object available in SQL or are you talking about shelling from VB? If it is available in SQL how can I find it in the help?
Thanks again,
Bob
Thanks for your help. Is the Shell/Process object available in SQL or are you talking about shelling from VB? If it is available in SQL how can I find it in the help?
Thanks again,
Bob
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Another technique is for the first procedure to start a job - create the job even if it has to, and then return. Job is running second procedure.
HTH
David