Sunday, November 6, 2011

Solution to basic problems faces by Freshers while doing database Operations

 set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[sp_appraise]
@DailyWages numeric(15,3),
@Level int,
@empid int,
@daysofworking int

as
declare @gross numeric(15,3),@special_allowance numeric(15,3),@med_allwnc numeric(15,3),@HRA numeric(15,3),@deduction numeric(15,3)
declare @pttax numeric(15,3),@pf numeric(15,3),@it numeric(15,3),@NetAmount numeric(15,3),@Basicsalary numeric(15,3)

begin

set @Basicsalary=@DailyWages*@daysofworking
set @special_allowance=@Basicsalary*0.08
set @med_allwnc=@Basicsalary*0.15
set @HRA=@Basicsalary*0.10
set @gross=@special_allowance+@med_allwnc+@HRA+@Basicsalary
if @Level = 1
set @pttax = 250
if @Level = 2
set @pttax = 300
if @Level = 3
set @pttax = 400
if @Level = 4
set @pttax = 500


set @pf=@gross * 0.15
set @it=@gross * 0.10

set @deduction=@pttax + @pf + @it
set @NetAmount=@gross - @deduction

select @empid as EmployeeCode,@DailyWages as Daily_Wages,@Level as Level,@daysofworking as Days_Of_Working,@Basicsalary as Basci_Salary,
@special_allowance as Special_Allowance,@med_allwnc as Medical_Allowance,@HRA as HRA,@gross as Gross_Salary,@pf as PF,@it as IT_Tax,@deduction as Total_Deduction,@NetAmount as NetAmount
end