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面试题(1)
create table testtable1
(
id int IDENTITY,
department varchar(12)
)
select * from testtable1
insert into testtable1 values('设计')
insert into testtable1 values('市场')
insert into testtable1 values('售后')
/*
结果
id department
1 设计
2 市场
3& ......
一、数据库版本
数据压缩在Sql Server 2008上才支持,2005不行,并且还要是企业版。我常常忘了这一点,在2005的Studio上闹出语法错误的状况,折腾浪费了好一阵才醒悟过来。
二、压缩状况
大约可以节省20%-50%的空间,并且行压缩和页压缩有所区别。
但让我失望的是,像含有Varchar(max),xml这种字段类型的,反而似乎压 ......
public static void main(String[] args) {
Session session = null;
Transaction tx = null;
List list = null;
&nb ......
/// <summary>
/// 过滤标记
/// </summary>
/// <param name="NoHTML">包括HTML,脚本,数据库关键字,特殊字符的源码 </param>
/// <returns>已经去除标记后的文字</returns>
&nbs ......
.errInfo
{
border:solid 1px #d00;
background:#F7F0F7;
}
1.URL地址防注入:
//过滤URL非法SQL字符
var sUrl=location.search.toLowerCase();
var sQuery=sUrl.substring(sUrl.indexOf("=")+1);
re=/select|update|delete|truncate|join|union|exec|insert|drop|count|&r ......