Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Stored Procedure Help

Author  Topic 

sheldondsouza
Starting Member

1 Post

Posted - 2007-10-12 : 11:50:43
First of all a big thanks for the guys of asp.net who helped me out to finish my web

forms. Since that is done and everything is debugged and validated. I need to finish of

one part which is supposed to be a store procedure.

I need this stored procedure to run at certain time. Well someone gave me a tutorial of a

job and how to create it. The main thing is how to i actually create a stored procedure.

I am very new and have never created a stored procedure before.

----------------------------------------------
Let me first tell you abt the site
----------------------------------------------

A user register and his username,password and this first name are stored in a table in

Sql server as users.

Next he can login in the main form which cross checks this data from users table. Once

entered he clicks on sigin. Here his username,startdate,startime and completed (NO) are

saved in the table called Time. When he goes to signout he clicks on the grid and updates

enddate and endtime and completed (Yes) in the same table.

Now what to do if he is absent?

Cannot allow someone to choose his name and save the absent details.

Have a table called absent which consists of username, date and reason. There is a form

for the user to update the reason only.

*Now lets say a user is absent i want the stored procedure to check the table users. IF

there are say 10 users, it will first take user1 and then check if the username is

present in the signout table where the startdate is equal to todays date. If it is not

there then save the username along with todays date in the absent table while the reason

is left null.

It should then move to the next user till the end of the number of entries in the user

table. If it does exist then dont do anything and just move on to the next users in the

table.

------------------------------------------------------

There is another table called leave which consist of username,startdate,enddate,completed
Now if the user schedules a leave, he should not be marked absent in the absent table. So

it must be checked that if todays date exist between the startdate and enddate.This

should be done for all the entries in the leave table.

So first the stored procedure must check if he is on leave or not, if he is not then call

the first part then do the * part. Else if he is on leave dont execute the *

------------------------------------------------------

Lastly if the entries in leave column where the enddate field matches the todays date.The

in that entry update the completed from No to Yes. Similary it should check all the

entries.


------------------------------------------------------
Each table has an ID which is acting like an autonumber and is the primary key
------------------------------------------------------

My guess 3 stored procedures must be created here. Anyways if any know how to deal with

this situation thanks a million.


Sheldon

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2007-10-13 : 01:15:19
Post your table structure and desired output. It's far easier for people to assist that way.
Go to Top of Page
   

- Advertisement -