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

SQL Server函数大全

--聚合函数
use pubs
go
select avg(distinct price)  --算平均数
from titles
where type='business'
go 
use pubs
go
select max(ytd_sales)  --最大数
from titles
go 
use pubs
go
select min(ytd_sales) --最小数
from titles
go 
use pubs
go
select type,sum(price),sum(advance)  --求和
from titles
group by type
order by type
go 
use pubs
go 
select count(distinct city)  --求个数
from authors
go 
use pubs
go
select stdev(royalty) --返回给定表达式中所有值的统计标准偏差
from titles
go 
use pubs
go
select stdevp(royalty) --返回表达式中所有制的填充统计标准偏差
from titles
go 
use pubs
go
select var(royalty) --返回所有值的统计方差
from titles
go 
use pubs
go
select varp(royalty) --返回所有值的填充的统计方差
from titles
go 
--数学函数 
select sin(23.45),atan(1.234),rand(),PI(),sign(-2.34) --其中rand是获得一个随机数
--配置函数
SELECT @@VERSION --获取当前数据库版本
SELECT @@LANGUAGE --当前语言
--时间函数
select getdate() as 'wawa_getdate' --当前时间
select getutcdate() as 'wawa_getutcdate' --获取utc时间
select day(getdate()) as 'wawa_day' --取出天
select month(getdate()) as 'wawa_month' --取出月
select year(getdate()) as 'wawa_year' --取出年
select dateadd(d,3,getdate()) as wawa_dateadd --加三天,注意'd'表示天,'m'表示月,'yy'表示年,下面一样
select datediff(d,'2004-07-01','2004-07-15') as wawa_datediff --计算两个时间的差
select datename(d,'2004-07-15') as wawa_datename --取出时间的某一部分
select datepart(d,getdate()) as wawa_datepart &n


相关文档:

SQL SERVER 2008的数据压缩


一、数据库版本
数据压缩在Sql Server 2008上才支持,2005不行,并且还要是企业版。我常常忘了这一点,在2005的Studio上闹出语法错误的状况,折腾浪费了好一阵才醒悟过来。
二、压缩状况
大约可以节省20%-50%的空间,并且行压缩和页压缩有所区别。
但让我失望的是,像含有Varchar(max),xml这种字段类型的,反而似乎压 ......

SQL Server全文索引的个人总结(上) 关于中文分词


SQL Server全文索引的个人总结(上) -关于中文分词
(2005-11-14 04:29:44)
转载
 
分类:深度研究
大家都知道LIKE查询很慢,全文索引就是事先做好相关的索引,表示哪个主题词可以在哪些记录里找到,甚至事先计算好RANK,检索时可以把相关度高的先列出来,这可以大大提高检索的速度。
打个比方,你有 ......

SQL中case when then的使用实例

假设现在News表有以下字段
News_Id,News_Title,News_IsSetTop,News_SetTopTime
其中News_IsSetTop(char(1))是“是否置顶”的含义;News_SetTopTime(DateTime)是置顶时间;
现在要实现:如果News_IsSetTop为"1"时 ,ORDER BY News_IsSetTop DESC,News_Id DESC;News_IsSetTop为"0"时,ORDER BY News_ID DESC ......

SQL Server日期

---一个月的第一天
SELECT DATEADD(mm, DATEDIFF(mm,0,getdate()), 0) 
--- 本周的星期一
SELECT DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
---一年的第一天
SELECT DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)
----季度的第一天
SELECT DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)
----上个月的最后一天
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号