---创建带参存储过程
go
if exists(select * from sysobjects where name='VMode_BaseOrWelfare')
drop procedure VMode_BaseOrWelfare
go
--创建存储过程
-- =============================================
-- Author: <milijiangjun>
-- Create date: <2019-07-30>
-- Description: <sql server>查询未停薪的 工资明细 不包含实习生的 社保信息
-- =============================================
create procedure VMode_BaseOrWelfare
@CheckTime Date--- 参数
as
/*******************************************
* 存储过程调用方法:
exec VMode_BaseOrWelfare @CheckTime = '2019-07-01',@Type = '1'
*******************************************/
begin
select BaseInfo.UserStaffId,BaseInfo.IdentityTypeCard,BaseInfo.UserName ,BaseInfo.IsPractice,Welfare.* from SalaryBaseInfo as BaseInfo
inner join CompanyWelfareSalary as Welfare
on BaseInfo.Id = Welfare.BaseInfoId
where BaseInfo.UserSalaryStatus = 1 and BaseInfo.SalaryInType = '工资明细' and BaseInfo.Id !=(select Id from SalaryBaseInfo where IsPractice = '实习生')
and Welfare.CompanyWelfareTime = @CheckTime
order by BaseInfo.UserStaffId
end
go
-- 调用存储过程
exec VMode_BaseOrWelfare '2019-07-01'
这样,在打开存储过程create 到sql 查询中的时候,就会带上参数的信息了。