473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 3322

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 ( )...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.