HR辅助工具中用到的SQL语句
2013-02-28 23:26
141 查看
select distinct id,Record_DateTime from HR_Record Where DATEDIFF(day,record_datetime,'2012-10-9')=0 AND ID not in(select ID from EmployyAttRecord where DATEDIFF(day,attdate,'2012-10-9')=0)
update EmployyAttRecord set Att0= hr_record.record_time from HR_Record ,employyattrecord where datename(hour,record_time)='8' and hr_record.id=employyattrecord.id and datediff(day,Record_DateTime,'2012-10-9')=0 and datediff(day,attdate,'2012-10-9')=0
USE [hr] GO /****** Object: StoredProcedure [dbo].[sp_CreatByEmploy_EmployAttRecord] Script Date: 02/28/2013 23:11:14 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= ALTER PROCEDURE [dbo].[sp_CreatByEmploy_EmployAttRecord] -- Add the parameters for the stored procedure here @Action int, @AttDate date AS DECLARE @returnResult int BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here -- Action =0 Create new list of current date . -- =1 delete old list & Create new list. if(@Action=1) begin delete From EmployyAttRecord where DATEDIFF(day,attdate,@attdate)=0 end insert into EmployyAttRecord (id,attdate) select id,@AttDate as AddDate from EmployyTable Set @returnResult= @@rowcount insert into EmployyAttRecord (id,attdate) select distinct id,@AttDate from HR_Record Where DATEDIFF(day,record_datetime,@Attdate)=0 AND ID not in(select ID from EmployyAttRecord where DATEDIFF(day,attdate,@Attdate)=0) set @returnResult=@returnResult+@@ROWCOUNT return @returnResult END
select * from HR_Record ,employyattrecord where datename(hour,record_time)='8' and hr_record.id=employyattrecord.id and datediff(day,Record_DateTime,'2012-10-9')=0 and datediff(day,attdate,'2012-10-9')=0 order by EmployyAttRecord.id
相关文章推荐
- SQL语句生成器 辅助开发工具【3月7日更新】
- 【求助】使用SQL语句优化工具遇到的问题
- 项目中用到的sql语句(case when...then... end )
- 【转】sql语句优化工具LECCO SQL Expert
- 向大家推荐一些编写SQL时带智能提示的辅助工具
- 微软官方提供的用于监控MS SQL Server运行状况的工具及SQL语句
- 以“&字段名”作为变量的SQL语句解析用到思路和方法
- 给大家分享一款学习sql语句的工具--DBeaver
- SQL实验用到的语句集合二
- LECCO SQL Expert工具之优化sql语句
- 【求助】使用SQL语句优化工具遇到的问题
- 测试sql性能的一些有用的辅助语句
- MXQ_SQL_数据库辅助工具V1.2
- shawl.qiu c# .net 自动生成 OleDb 数据操作语句小工具 Producing OleDbSql 1.1
- 工作中用到的SQL语句
- [sql]sqlserver用到的sql语句。。。
- dhl:有用的sql语句(我用到的)更新中....
- 工作——宏观部分用到的SQL语句
- MYSQL学习笔记——sql语句优化工具
- 如何用MYsql-Front工具抒写sql语句,创建出一个自己想要的数据库