Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hai....

Write a Stored procedure in SQL Employee working more then 8 howers. Every one hower this
Salary is double than normal howers (Daily working howers is 8 howers)

create three tables: 1.Shifts,2.employee,3.timesheet
Insert into shift values(emp_code int,shift_name varchar(),shift_time time);
Insert into employee values(emp_code int,emp_name varchar(),grade varchar(),dept varchar(), salary int);
Insert into timesheet values(emp_code int,date _in date,time_in time,time_out time,date_out date);

"Using above Three table and write SP"

Example:

Per day normal working howers is :8 howers
per howers salary 100 rupes
Daily salary =8*100=800
Spend extra 1 hower =1*100 (normal salary)+salary double
=1*100+100=200
Spend extra 2 howers=2*100 (normal salary)+salary double
=2*100=200+200(salary double)=400
Plz Send Stored procedure in SQL ((Using above Three Tables))

Thanks and regard's

Venkatesh D

What I have tried:

Sorry I know the basic of sp so i don't try
Posted
Comments
deepankarbhatnagar 16-Feb-16 7:42am    
Have u tried. We are not here for spoon feeding. Where do you stuck. please show your code, we will try to resolve it...
F-ES Sitecore 16-Feb-16 7:43am    
We're not here to do your homework for you.

1 solution

"Sorry I know the basic of sp so i don't try"

Sorry, but we aren't here to do your homework for you, particularly if you can't be bothered to try, or learn anything.
That kind of attitude will not get you very far - or a good job. All you will do is annoy people, and annoyed people don't help much.
So start here: Sql Server - How To Write a Stored Procedure in SQL Server[^] and here: https://msdn.microsoft.com/en-GB/library/ms345415.aspx?f=255&MSPPError=-2147217396[^]
And give it a try.
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Comments
Member 12330797 17-Feb-16 1:42am    
Hai... i am trying some one (using one table) output is correct
But using tree tables plz send any syntax or any one

create procedure empsalary
(
@empcode varchar(60)
)
as
begin
declare @working_hours int
declare @fixed_salary_hour float
declare @extra_time int
declare @extra_salary float
declare @time int
declare @salary float

select @working_hours=DATEDIFF(hour,timein,timeout) from timesheet where
empcode=@empcode
if @working_hours<=8
begin
select @salary=@working_hours*30
print @salary
end
else if @working_hours>8
begin
select @extra_time=@working_hours-8
select @extra_salary=(@extra_time*60)
print @extra_salary
end
end

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900