DECLARE @days INT, @date_start DATETIME = '2016-11-01', @date_end DATETIME = '2016-11-10' SET @days = DATEDIFF(DAY, @DATE_START, @DATE_END); SELECT DAY(DATEADD(dd, number, @DATE_START)) AS 日期 FROM master.dbo.spt_values WHERE type = 'p' AND number <=…
1.查询某时间段内日期列表 select level,to_char(to_date('2013-12-31','yyyy-mm-dd')+level-1,'yyyy-mm-dd') as date_time from dual connect by level <=to_date('2014-01-03','yyyy-mm-dd')-to_date('2013-12-31','yyyy-mm-dd')+1 2.查询前两个月日期列表 SELECT T.DATE_ID FROM ( ,)+ row…
取所有月份: declare @begin datetime,@end datetime set @begin='2015-2-6' set @end='2015-12-2' declare @months int set @months=DATEDIFF(month,@begin,@end) select convert(varchar(7),DATEADD(month,number,@begin) ,120) AS 月份 from master.dbo.spt_values where ty…
declare @start datetime declare @end datetime set @start = '2018-01-25' set @end = '2018-02-03' select dateadd(dd,num,@start) FROM (SELECT ROW_NUMBER() OVER (ORDER BY ID)-1 AS num FROM sysobjects) KK where dateadd(dd,num,@start) <=@end --2018-01-25 0…
MS SQL SERVER 获取当前数据库文件等信息,适用于多个版本: SELECT dbf.file_id AS FileID , dbf.name AS [FileName] , s.filename AS FileLocation , CAST(dbf.size/128.0 AS DECIMAL(19,2)) AS FileSizeMB , CAST(CAST(FILEPROPERTY(dbf.name, 'SpaceUsed') AS int)/128.0 AS DECIMAL(…