SqlServer计算每个月的第一天,最后一天,最后一天
--每个月的第一天
select dateadd(dd,-datepart(dd,getdate())+1,getdate())
--第个月的最后一天
select dateadd(dd,-datepart(dd,getdate()),dateadd(mm,1,getdate()))
--本月的天数
select datediff(dd,getdate(),dateadd(mm,1,getdate()))
相关文档:
E盘根目录新建一个Excel文件aa.xls后测试如下代码
use tempdb
go
if (object_id ('udf_getExcelTableNames' ) is not null )
drop function dbo .udf_getExcelTableNames
go
create function udf_getExcelTableNames (@filename varchar (1000 ))
returns @t table (id int , name varchar ( ......
在Google上使用“sql 分页”关键字进行搜索,几乎所有的答案都是那三条。其二效率最高,其三使用游标,效率最差。
下面是那三种方法 (插入代码没有sql选项)
方法1:
适用于 SQL Server 2000/2005
SELECT TOP 页大小 *
from table1
WHERE ......
临近年终,在工作之余对工作和学习中遇到的问题以及常用的一些知识点做了些整理,以备后用。本文涉及的内容为数据库,算是对开发总结(1)---数据库一文的补充。
1 对于主键设置了Identity的表,在删除表中数据后再往表中插入数据,Identity列不是从1起始了,如果想删除数据后Indentity列仍从1起始,可以用下面代码来删除数据 ......
SQLSERVER--一些经典问题总结
2007-04-01 01:04:06
大中小
/**********************************/
--获得某一天所在年的第一天
declare @a datetime,@b datetime,@sum int,@num int,@res varchar(20)
select @a='1-6-1968'
select @b='2006-4-8'
select @sum=year(@a)
select @res=ltrim(cast(@sum as ......