if exists(SELECT *FROM [DBPersonnel].[dbo].[TB証明書] where [社員*]='')
update [DBPersonnel].[dbo].[TB証明書] set [身分証明書]='' where [社員*]=''
else
INSERT INTO [DBPersonnel].[dbo].[TB証明書] ([社員*],[身分証明書],[卒業証書])
VALUES ('','sssss','ssssss') 取得本月天数
select datediff(day,cast(month(GetDate()) as varchar)+'-'+cast(month(GetDate()) as varchar)+'-15' ,cast(month(GetDate()) as varchar)+'-'+cast(month(GetDate())+ as varchar)+'-15') 一个季度多少天
declare @m tinyint,@time smalldatetime
select @m=month(getdate())
select @m=case when @m between and then
when @m between and then
when @m between and then
else end
select @time=datename(year,getdate())+'-'+convert(varchar(),@m)+'-01'
select datediff(day,@time,dateadd(mm,,@time)) 判断是否闰年: SELECT case day(dateadd(mm, , dateadd(ms,-,DATEADD(yy, DATEDIFF(yy,,getdate()), )))) when then '平年' else '闰年' end
或者
select case datediff(day,datename(year,getdate())+'-02-01',dateadd(mm,,datename(year,getdate())+'-02-01'))
when then '平年' else '闰年' end 所有休息日
DECLARE @Work_LegalHoliday TABLE
(
ID VARCHAR(36) ,
DateTimeName DATETIME ,
WeekName VARCHAR(50) ,
IsLegalHoliday INT ,
Remark NVARCHAR(MAX)
)
DECLARE @Year INT
SET @Year = 2015
--
;
WITH tbSource
AS ( SELECT CAST(RTRIM(@Year) + '-01-01' AS DATETIME) DateTimeName
UNION ALL
SELECT DATEADD(dd, 1, DateTimeName)
FROM tbSource
WHERE DATEPART(yy, DATEADD(dd, 1, DateTimeName)) = @Year
)
INSERT @Work_LegalHoliday
SELECT NEWID() ,
CONVERT(VARCHAR(10), DateTimeName, 121) ,
DATENAME(WEEKDAY, DateTimeName) ,
0 ,--不是法定假日
'' AS Remark
FROM tbSource a
WHERE DATEPART(WEEKDAY, a.DateTimeName) = 1
OR DATEPART(WEEKDAY, a.DateTimeName) = 7
EXCEPT
SELECT NEWID() ,
CONVERT(VARCHAR(10), DateTimeName, 121) ,
DATENAME(WEEKDAY, DateTimeName) ,
0 ,
'' AS Remark
FROM @Work_LegalHoliday
OPTION ( MAXRECURSION 0 )
SELECT *
FROM @Work_LegalHoliday