易截截图软件、单文件、免安装、纯绿色、仅160KB

sql获取日期

declare
 @aa varchar(20)
set @aa= CONVERT(varchar(100), GETDATE(), 23)
--//日
print @aa+' 0:00:00.000'
print @aa+' 23:59:59.999'
--//周
print CONVERT(varchar(100), DATEADD(wk, DATEDIFF(wk,0,getdate()), 0), 23)+' 0:00:00.000'
print CONVERT(varchar(100), DATEADD(wk, DATEDIFF(wk,0,getdate()), 6), 23)+' 23:59:59.999'
--//月
print CONVERT(varchar(100), DATEADD(m, DATEDIFF(m,0,getdate()), 0), 23)+' 0:00:00.000'
print CONVERT(varchar(100), DATEADD(m, DATEDIFF(m,0,getdate()), 30), 23)+' 23:59:59.999'
select distinct (userid),sum(score) as SumScore from ph where endTime between @aa+' 0:00:00.000' and @aa+' 23:59:59.999' group by userid order by SumScore desc
select distinct (userid),sum(score) as SumScore from ph where endTime between CONVERT(varchar(100), DATEADD(wk, DATEDIFF(wk,0,getdate()), 0), 23)+' 0:00:00.000' and CONVERT(varchar(100), DATEADD(wk, DATEDIFF(wk,0,getdate()), 6), 23)+' 23:59:59.999' group by userid order by SumScore desc
select distinct (userid),sum(score) as SumScore from ph where endTime between CONVERT(varchar(100), DATEADD(wk, DATEDIFF(wk,0,getdate()), 0), 23)+' 0:00:00.000' and CONVERT(varchar(100), DATEADD(wk, DATEDIFF(wk,0,getdate()), 6), 23)+' 23:59:59.999' group by userid order by SumScore desc


相关文档:

Microsoft SQL Server 查询处理器的内部机制与结构

摘要:本文介绍了在客户机上处理 Microsoft sql server(WINDOWS平台上强大的数据库平台) 查询的方式,各种客户机与 sql server(WINDOWS平台上强大的数据库平台) 的交互方式,以及 sql server(WINDOWS平台上强大的数据库平台) 在处理客户机程序的请求时需要完成的工作。
简介
  Microsoft(R) sql server(WINDOWS平台上强 ......

EXCEL转数据到SQL(已有表结构)

insert into Country123 ([Country_Id], [Region_ID], [Country_EN_Name], [Country], [Country_ALL_ID], [Country_Order_Id]) select [Country_Id], [Region_ID], [Country_EN_Name], [Country], [Country_ALL_ID], [Country_Order_Id] from openrowset( 'Microsoft.Jet.OLEDB.4.0', 'EXCEL 5.0;HDR=YES;IMEX=1; DATABASE= ......

SQL Server 2005 UNIQUE 约束

SQL Server 2005:
ALTER Table Content_Node
ADD CONSTRAINT uc_TREECODE UNIQUE (TreeCode)
ALTER TABLE Content_Node
DROP CONSTRAINT uc_TREECODE
约束所在字段长度设为896,因为UNIQUE约束的最大键长度为 900 字节,而UNIQUE约束默认占有4字节。
参考:http://www.w3school.com.cn/sql/sql_unique.asp ......

SQL SERVER 2000 连接不上的解决方法

1。如果装sql server中未出现异常的话,且一些自选参数,账户,密码等没有错误的话。一旦出现诸如socket建立不起,连接不上等问题。最有效的解决方法是打补丁,其中sp4:http://www.microsoft.com/downloads/details.aspx?DisplayLang=zh-cn&FamilyID=8e2dfc8d-c20e-4446-99a9-b7f0213f8bc5,sp3a:http://www.microsof ......

SQL参数化

SqlCommand com = new SqlCommand("select * from myuser where username=@UserName and password=@Pwd", con);
           
            com.Parameters.Add(new SqlParameter("@UserN ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号