Running SQL Server stored procedure 'out-of-session' - sql-server

From a (classic ASP on IIS) web-page a stored procedure is called in SQL Server. The program waits till the stored procedure returns a result but this is not at all necessary. Is there a way to just start the stored procedure and go on?
Mabel

I suggest you to put this SP into the job. Then launch job from IIS. Also you can use asynchronous SP launch (you can read here about it).

Related

SQL Server - schedule a one-time task to run after a currently running task finishes?

I'm running a stored procedure right now that will likely take 12 hours to complete, however the exact actual time is unknown. I have another stored procedure that I need to run once the currently running one is finished. Is it possible in SQL Server to schedule something to run, one time, e.g. "after dbo.storedProcedureName completes execution"?
Yesterday I tried the schedule option in SQL Server Agent called "Start whenever the CPU's become idle" but this did not work.
This may be possible with some add-in, or with a loop monitoring running processes, but it isn't really the best way. Instead, you should set up an SQL Script to run the two in sequence, e.g.:
EXEC dbo.MyLongRunningProc;
EXEC dbo.MyOtherProc;
These are guaranteed to run in sequence, one right after the other, when run from inside SSMS or a similar tool.
You can create and execute (or schedule) a procedure that runs both
create procedure runBothInOrder
as
begin tran
exec procedure1
exec procedure2
commit

SQL Server : execute stored procedure and disconnect SSMS, how can I do that?

I am using Azure SQL. I have a stored procedure. It does not returns any results. The stored procedure takes a long time to complete (4-5 hours).
My question is: I want to execute the stored procedure from Management Studio and let it run until it completes. While it is running, I want to disconnect Management Studio.
How can I do that?

Are sql triggers run in a separate thread?

If I want to return the user a web page and write to a log or word by word processing, should I use a stored procedure call from CLR in a new thread or just use sql triggers?
You can't make a SQL Server trigger run asyncronously. The best you could do is utilize SQL Server's Service Broker to execute a stored proc call.

Execute an Oracle stored procedure from a SQL Server stored procedure

I have a SQL Server stored proc that needs to send information to an Oracle stored proc.
How do I set this up? Should it be a linked server? And how do I write the code to pass and execute the stored proc?
You could also use:
DECLARE #outputParameter int
EXEC ('BEGIN <procedureName>(?,?); END;', #inputParameter , #outputParameter OUTPUT) at <linkedServerName>
This allows capturing output parameters
a procedure "TestingProcedure" in Oracle server.
a linked Server "LinkedServer" in SQL Server.
call TestingProcedure in SQL server example:
EXECUTE ('begin TestingProcedure; end;') AT LinkedServer;
This is the syntax that I would probably try from the start:
SELECT * FROM OPENQUERY(<linked server name>, '{CALL <oracle sp>}')
What I've seen (I have not tried this myself) is that you can also use OPENQUERY to call an Oracle function which can then call the stored procedure, or you can turn the stored procedure into a function. Your connection from SQL Server would then look something like this:
SELECT * FROM OPENQUERY(<linked server name>, 'SELECT <oracle function> FROM dual')
Turns out I ended up having to use Microsofts CLR and write my own little C# application in order to handle the variables being pushed between the servers. Here's what I did:
C# Application starts on a scheduled task in windows
Application executes the SQL Server stored procedure and gets the return values
Application then executes the Oracle stored procedure with appropriate values

SSRS Stored Procedure (Timing Out?). Using too many Linked Servers?

We are using one shared data source ds1 that connects to a server main_server which holds all the stored procedures to generate our reports.
One of the stored procedures usp1 simply executes another stored procedure on another server another_server:
exec another_server.another_database.dbo.usp1
When I execute usp1 on main_server, everything works fine. It runs at almost the same speed as if I had just gone to another_server and executed from there.... Which is what I expected...
However, when I try to run the report from our report server, it fails. When I watch it run, it almost immediately goes into suspended mode and stays there.
We have all of our timeouts set to 40 minutes, so that shouldn't be our issue, since the report runs in 15. Any thoughts?
Thanks...
Maybe the account reporting services uses to run the report doesnt have the correct access or rights to run an sp on another server?
With linked servers your stored procedure may copy ALL the data it needs before doing any joins.
Check out:
http://blogs.msdn.com/b/dataaccesstechnologies/archive/2010/06/30/linked-server-performance-heterogeneous-databases.aspx

Resources