1、日期函数dateadd进行加减年月日小时,拼接标准日期格式
1、set fldDate=Convert(date,dateadd(hour,-1,Convert(datetime,fldDate + ' ' +CONVERT(varchar(2),fldTime)+':00:00'))),fldTime=DATEPART(HOUR,dateadd(hour,-1,Convert(datetime,fldDate + ' ' +CONVERT(varchar(2),fldTime)+':00:00')))
2、len函数判断字符串长度有case when then else end 进行填补日期类型
2、case When len(fldMonth)=1 then '0'+convert(varchar(2),fldMonth) else convert(varchar(2),fldMonth) end
3、根据一张表的内容复制到另一张表要写出所对应的字段重要,几个日期函数顺便提一下
3、insert into tblEQIA_RPI_Basedata (fldSTCode,fldPCode,fldSYear,fldSMonth,fldSDay,fldSHour,fldSMinute,fldEYear,fldEMonth,fldEDay,fldEHour,fldEMinute ,fldItemCode ,fldItemValue ,fldSource,fldUserID) select '210200',fldPCode,YEAR(F2),MONTH(F2),DAY(F2),0,0,YEAR(F2),MONTH(F2),DAY(F2),23,59,fldItemCode,F3,0,0 from dbo.Sheet1$ inner join tblEQIA_R_Point on F1=fldSort inner join tblEQIA_R_Item on F4=fldItemName where tblEQIA_R_Point.fldYear =2011
4、删除表进行条件判断是否存在
1 4、delete tblEQIP_S_CompanyInfo from tblEQIP_S_CompanyInfo T where 2 exists( 3 select 1 from tblEQIP_S_CompanyInfo where fldMonitorYear=T.fldMonitorYear and fldDistrictCode=T.fldDistrictCode and fldCompanyName=T.fldCompanyName 4 and fldAutoID < T.fldAutoID 5 )