sql server 语句日志

----------建表脚本
USE [oa]
GO
/****** 对象:  Table [ezoffice].[OA_LEAVERETURN_REGISTER]    脚本日期: 04/07/2012 08:57:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [ezoffice].[OA_LEAVERETURN_REGISTER](
 [id] [int] IDENTITY(1,1) NOT NULL,
 [userID] [varchar](20) NULL,
 [userName] [varchar](32) NOT NULL,
 [objectName] [varchar](300) NOT NULL,
 [leaveDate] [datetime] NOT NULL,
 [returnDate] [datetime] NULL,
 [photoName] [varchar](200) NULL,
 [remarks] [varchar](200) NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

---------------增加自动生成id语句
alter table LeaveReturnRegister add id int identity(1,1);


------------------------------------

insert into ezoffice.OA_LEAVERETURN_REGISTER values('wuyutao2','合肥市保险公司',getdate(),getdate(),'20120402_3456','');

select * from ezoffice.OA_LEAVERETURN_REGISTER order by id desc


delete ezoffice.OA_LEAVERETURN_REGISTER where 1=1 and ( id=1 or id=2 or id=3)
----拼接字符串
update ezoffice.OA_LEAVERETURN_REGISTER set empName=convert(varchar(100),id)+empName

insert into ezoffice.OA_LEAVERETURN_REGISTER values('wuyutao2','合肥市保险公司',getdate(),getdate(),'20120402_3456','');

select * from ezoffice.OA_LEAVERETURN_REGISTER order by id desc


delete ezoffice.OA_LEAVERETURN_REGISTER where 1=1 and ( id=1 or id=2 or id=3)
update ezoffice.OA_LEAVERETURN_REGISTER set returndate=returndate+id

select leavedate+1,returndate+1 from ezoffice.OA_LEAVERETURN_REGISTER order by id desc

update ezoffice.OA_LEAVERETURN_REGISTER set empName=convert(varchar(100),id)+empName


(('2012-04-23 08:25:13' > po.leaveDate and  '2012-04-28 08:25:13' < po.leaveDate) or ('2012-04-23 08:25:13' > po.returnDate and  '2012-04-28 08:25:13' < po.returnDate))


select * from ezoffice.OA_LEAVERETURN_REGISTER where '2012-04-23 08:25:13' < leavedate and '2012-05-23 08:25:13' >leavedate

select * from ezoffice.org_employee


select max(id) from ezoffice.OA_LEAVERETURN_REGISTER

select * from ezoffice.OA_LEAVERETURN_REGISTER order by id desc
select * from ezoffice.OA_LEAVERETURN_REGISTER  where empName='104104蒋正'

update ezoffice.OA_LEAVERETURN_REGISTER set returndate=null where id =104

原文地址:https://www.cnblogs.com/anuoruibo/p/2442268.html