Solved

Changing Stored Procedure Execution Context

Posted on 2007-11-19
9
228 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
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 10

Accepted Solution

by:
MrClyfar 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
 
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now