472,955 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,955 software developers and data experts.

schedule sql server stored procedures defined in a table??

I have a growning list of stored procedures that accept a single string
as a parameter.

The list and parameters are maintained in a table with two columns.

Some of the Stored procedures take hours to complete.
>From asp.net, I want users to be able to select and launch the stored
procedures and the page come right back and recording infomation about
the stored procedure (like a job number) that can later be used to
report what stored procedures are still running.

Can I do this in ASP.NET via ADO.NET and sql commands?

If possible I don't want to create an sql server 2005 job for every
stored procedure. If possible, not have to create any jobs at all. I've
been able to do the above with an Oracle Procedures and the same
asp.net solution using DBMS.Job_Submit.

Jan 18 '07 #1
1 3295

You can work something like this. Here are my ideas...........
Create a "holding" table for each stored procedure.
What I mean by this is that this is where your parmeters can do for a stored
procedure.

Let's say you needed to call a procedure called
uspUpdateEmployeeHistory

instead of having

uspUpdateEmployeeHistory (empid int)

just have it as

uspUpdateEmployeeHistory
......

Ok.

Then create a "holding table"

create table UpdateEmployeeHistoryHoldingTable (empid int)

.......
Ok
uspUpdateEmployeeHistory is smart enough to look in the holding table for
parameters.

..........

Ok next step, create a

StoredProceduresToRun table

create table StoredProceduresToRun ( uspname varchar(128) )

........

whenever you need a job to run, you just pop an entry into this table.

......

Finally, you schedule 1 job. I guess to run every 1 minute for example.

You also have a stored procedure. called
uspCheckJobToRunTableAndRunJob
.......

the schecued job will always call uspCheckJobToRunTableAndRunJob when it
runs.
uspCheckJobToRunTableAndRunJob contains code to look at the
StoredProcecursToRunTable

then using dynamic sql, you can call

declare @usp varchar(128)
select @usp = top 1 uspname from StoredProcecursToRunTable

if (@usp IS NOT NULL)
begin
EXEC ( @usp )
end
You'll have to write a cursor (ahhhhh?) to handle the multi records in
StoredProcecursToRunTable

.......
Ok..

Finally, you want something to fire.

When you actually need an employee history to update , you do this:
INSERT INTO UpdateEmployeeHistoryHoldingTable (empid ) values 1001
INSERT INTO StoredProceduresToRun (uspname) values
'uspUpdateEmployeeHistory'
.......

Then, when the job goes off 1 to 60 seconds later (because it fires every
minute).......

eventually

EXEC 'uspUpdateEmployeeHistory' will run (via the EXEC ( @usp ) above)

and remembering that
'uspUpdateEmployeeHistory' is smart enough to find the "1001" value in the
UpdateEmployeeHistoryHoldingTable table.
Kinda hacky, but it'll get the job done.
PS
I like the "holdingtable" idea, because then you're not screwed if you need
to go to 2 parameters for each stored procedure.
And, if you get duplicates in your holding table, its not a big idea.
Like if 1001 (empid) got added to the UpdateEmployeeHistoryHoldingTable 55
times, you only need to run it once.
select distinct empid from UpdateEmployeeHistoryHoldingTable
Make any sense?
I call this poor man's async processing.


When you need to update the history of any employee
"jobs" <jo**@webdos.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
I have a growning list of stored procedures that accept a single string
as a parameter.

The list and parameters are maintained in a table with two columns.

Some of the Stored procedures take hours to complete.
From asp.net, I want users to be able to select and launch the stored
procedures and the page come right back and recording infomation about
the stored procedure (like a job number) that can later be used to
report what stored procedures are still running.

Can I do this in ASP.NET via ADO.NET and sql commands?

If possible I don't want to create an sql server 2005 job for every
stored procedure. If possible, not have to create any jobs at all. I've
been able to do the above with an Oracle Procedures and the same
asp.net solution using DBMS.Job_Submit.

Jan 20 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Jeager | last post by:
Why is it, Microsoft manage to write operating systems and office applications with every bell and whistle facility known to man. Yet, even after years and years of development they still cannot...
5
by: Raquel | last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it seems to run fine but returns NOTHING. I mean..as if nothing has happened..not resultset is returned. I am passing value...
1
by: Roman Prigozhin | last post by:
Hi all, I have one stored procedure where I defined 3 temporary tables, which i return back to java. I want to have 3 separate sub procedures which would go after the data and fill out these...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
4
by: shark | last post by:
hi, it might be a very stupid question but i want to know whether an execution plan is created in user defined functions in sql server 2000 like stored procedures. Thanks.
10
by: J. S. EDV | last post by:
Hello, I have got a little problem with stored procedures and C#. I have got a stored procedure which should only insert something in a table. For example: ALTER PROCEDURE DBO.PROC1 AS...
1
by: peaceburn | last post by:
Hi, I'm gonna pull my hair in the coming days with these DB2 stored procedures. So the issue, let's assume a simple stored procedure like this : CREATE PROCEDURE MYSCHEMA.PROCEDURE1 ( )...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.