sql - payroll for employee in stored procedures wth TVP -


i'm trying generate employee payslips , store in db stored procedure encountered problems.

it pointing error execute:

must pass parameter number 4 , subsequent parameters '@name = value'. after form '@name = value' has been used, subsequent parameters must passed in form '@name = value'.

the parameters im inputing in are:

  1. start date
  2. end date
  3. employee hours worked information – table-valued parameter employee id , hours worked pay period.
  4. employee allowance information – table-valued parameter employee id, allowance type id , allowance amount.

code:

create type employeeinfo table  (     employeeid int     ,hoursworked int     ,primary key (         employeeid         ,hoursworked         ) ); go  create type allowanceinfo table  (     employeeid int     ,allowanceid int     ,allowanceamount decimal(7, 2)     ,primary key (         employeeid         ,allowanceid         ,allowanceamount         ) ); go  create procedure usp_createpayroll @startdate date     ,@enddate date     ,@taxid int     ,@nohoursworked employeeinfo readonly     ,@allowancebonus allowanceinfo readonly begin     insert payslip     select @startdate         ,@enddate         ,n.hoursworked         ,p.hourlyrate         ,p.hourlyrate * n.hoursworked         ,(p.hourlyrate * n.hoursworked) + a.allowanceamount         ,((p.hourlyrate * n.hoursworked) + a.allowanceamount) * t.taxrate / 100         ,@taxid         ,a.allowanceid         ,n.employeeid     @nohoursworked n         ,@allowancebonus         ,position p         ,employee e         ,tax t     p.positionid = e.positionid         , e.employeeid = n.employeeid         , t.taxid = @taxid end  declare @employeeinfo employeeinfo; declare @hoursworked int;  insert @employeeinfo select e.employeeid     ,@hoursworked employee e e.employeeid = 1     , @hoursworked = 160  declare @allowanceinfo allowanceinfo; declare @empinfo employeeinfo  insert @allowanceinfo select e.employeeid     ,a.allowanceid     ,a.allowanceamount employee e     ,allowance     ,@empinfo emp e.employeeid = emp.employeeid     , a.allowanceid = 1  execute usp_createpayroll @startdate = '1/1/2015'     ,@enddate = '1/31/2015'     ,@taxid = 2     ,@employeeinfo     ,@allowancebonus 

as error says, when used named parameters need parameters, looks should be:

execute usp_createpayroll       @startdate = '1/1/2015'     ,@enddate = '1/31/2015'     ,@taxid = 2     ,@nohoursworked = @employeeinfo     ,@allowancebonus = @allowanceinfo 

also, looks you're declaring variable declare @empinfo employeeinfo never filled data, used in join after it's been declared. maybe insert query references @empinfo supposed reference @employeeinfo ?


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -