--根据录入人获取工时统计信息
alter proc proc_GetWorkHourByEmpId
@key1 varchar(100), --关键字
@user_group1 varchar(100),--用户分组
as
begin
declare @SqlSelect nvarchar(2000),@ParmDefinition nvarchar(max);
set @SqlSelect=‘ select * from User where 1=1 ‘ --sql语句
set @ParmDefinition=N‘@key nvarchar(10),@user_group nvarchar(50) ‘; --参数声明
if(@key1 is not null and @key1!=‘‘)
begin
set @[email protected]+‘ and (Emp_Name like @key or Emp_Number like @key or Branch_Name like @key)‘
end
if(@user_group1 is not null and @user_group1!=‘‘)
begin
set @[email protected]+‘ and User_Grouping like @user_group ‘
end
--执行sql
EXEC sp_executesql @SqlSelect,@ParmDefinition,@[email protected],
@[email protected]_group1
end