sql创建带注释的存储过程

本文详细介绍了如何在SQL Server中创建一个带参数的存储过程,用于查询未停薪的工资明细,排除实习生的社保信息。该存储过程由milijiangjun于2019-07-30创建,通过内连接查询工资基本信息表和公司福利薪资表,筛选出符合条件的数据,并按员工工号排序。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

---创建带参存储过程
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 查询中的时候,就会带上参数的信息了。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值