本文主要向大家介绍了SQLServer数据库之SQL Server 获取本周,本月,本年等时间内记录,通过具体的内容向大家展现,希望对大家学习SQLServer数据库有所帮助. datediff(week,zy_time,getdate())=0 //查询本周datediff(month,zy_time,getdate())=0 //查询本月本季:select * from table where datediff(qq,C_CALLTIME,getdate())=0前半年1-6,后半年7-12…
datediff(week,zy_time,getdate())=0 //查询本周 datediff(month,zy_time,getdate())=0 //查询本月 本季:select * from table where datediff(qq,C_CALLTIME,getdate())=0 前半年1-6,后半年7-12:select * from table where datepart(mm,C_CALLTIME)/7 = datepart(mm,getdate())/7 1. 当前系…
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(…
SQL Server获取指定行(如第二行)的数据 --SQL Server获取指定行(如第二行)的数据-- --法一(对象法)-- select * from ( select * , number = row_number() over(order by Grade desc) from Students ) m where number = 2 --法二(排除法)--- select top 1 * from Students where Grade not in ( select…