Solved

Changing Stored Procedure Execution Context

Posted on 2007-11-19
9
241 Views
Last Modified: 2013-11-26
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?
0
Comment
Question by:rcl58
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 10

Accepted Solution

by:
Jason Evans earned 400 total points
ID: 20316577
Hi there.

What you could use here ia asynchronous command execution. Here's a good link which explains the concept:

http://www.devx.com/dotnet/Article/26747

Basically the idea is the your code makes an asynchronous call via ADO.NET to the Sql Server, thus whilst in the background this call is being made, the user can carry on their work.

Experiment with the example in the link, it should give you a good grounding.

Hope this helps.
Jas.
0
 
LVL 35

Expert Comment

by:David Todd
ID: 20316772
Hi,

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
0
 

Author Comment

by:rcl58
ID: 20316830
How do you start a job in the first procedure?

Thanks
Bob
0
How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

 
LVL 35

Expert Comment

by:David Todd
ID: 20316923
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
0
 

Author Comment

by:rcl58
ID: 20319426
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
0
 
LVL 35

Assisted Solution

by:David Todd
David Todd earned 50 total points
ID: 20322328
Hi,

The other scheduler is the Windows scheduler, but I'm not sure I'd try it in your context.

My impression is that what you are wanting to do is bigger than SQL Express ... that is, you have two options: 1) upgrade Express to Workgroup or Standard, 2) forget about using SQL Agent and use the suggestion about ado.net.

Cheers
  David
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20324210
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
0
 

Author Comment

by:rcl58
ID: 20326863
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
0
 
LVL 25

Assisted Solution

by:imitchie
imitchie earned 50 total points
ID: 20326889
i meant from VB
http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.aspx

Process.Start does not wait, the closest i can describe it is from the command window (cmd.exe)
"start excel.exe"    << doesn't wait
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question