SQL SERVER 函数(转)
SQLServer基本函数
1.字符串函数 :
字符操作类 :
upper(char_expr) 转为大写
lower(char_expr) 转为小写
UCase(string) 返回 Variant (String),其中包含转成大写的字符串。
LCase(string) 返回字符串的小写形式。
space(int_expr) 生成int_expr个空格
replicate(char_expr,int_expr) 复制字符串int_expr次
reverse(char_expr) 反转字符串
stuff(char_expr1,start,length,char_expr2) 将字符串char_expr1中的从 start开始的length个字符用char_expr2代替
ltrim(char_expr) rtrim(char_expr) 去掉空格
ascii(char) char(ascii) 两函数对应,取ascii码,根据ascii吗取字符
字符串查找 :
charindex(char_expr,expression) 返回char_expr的起始位置
patindex("%pattern%",expression) 返回指定模式的起始位置,否则为0
locate(substr,str,pos) 返回子串substr在字符串str第一个出现的位置
2.数学函数
abs(numeric_expr) 求绝对值
ceiling(numeric_expr) 取大于等于指定值的最小整数
exp(float_expr) 取指数
floor(numeric_expr) 小于等于指定值得最大整数
power(numeric_expr,power) 返回power次方
rand([int_expr]) 随机数产生器
round(numeric_expr,int_expr) 安int_expr规定的精度四舍五入
sign(int_expr) 根据正数,0,负数,,返回+1,0,-1
sqrt(float_expr) 平方根
exp(float x):求e的x次幂
tan(float x):计算x(弧度表示)的正切值。
atan(float x):求x(弧度表示)的反正切值
cos(float x):求x(弧度表示)的余弦值
acos(float x):求x(弧度表示)的反余弦值
sin(float x):计算x(弧度表示)的正弦值。
asin(float x):求x(弧度表示)的反正弦值
fabs(float x):求浮点数x的绝对值
fmod(float x, float y):计算x/y的余数
pow(float x, float y):计算x的y次幂。
sqrt(float x):计算x的平方根。
3.日期,时间函数
getdate() 返回日期
datename(datepart,date_expr) 返回名称
datepart(datepart,date_expr) 取日期一部份
datediff(datepart,date_expr1.dateexpr2) 日期差
dateadd(datepart,number,date_expr) 返回日期加上 number
4.系统函数
suser_name() 用户登录名
user_name() 用户在数据库中的名字
user 用户在数据库中的名字
show_role() 对当前用户起作用的规则
db_name() 数据库名
object_name(obj_id) 数据库对象名
col_name(obj_id,col_id) 列名
col_le
相关文档:
{
SqlConnection cnn = new SqlConnection
("context connection=true");
cnn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "select * from customers";
SqlDataReader reader = cmd.ExecuteReader();
SqlContext.Pipe.Send(reader);
reader.Close();
cnn.Close();
}
......
只需要在配置文件里 hibernate.show_sql=true
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
......
在sql中创建用户自定义拼音函数:
create function f_GetPy(@Str nvarchar(400))
returns nvarchar(4000)
as
begin
declare @strlen int,@re nvarchar(4000)
declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1))
insert @t select '吖','A' union all select '八','B'
union all select '嚓 ......
今天练习在JSP页面中实现分页效果,在查询语句方面牵扯到了top的用法。简要做一下总结:
为实现类似top的功能,我们在SQL Server中和MySQL中使用到的SQL语句是不同的。
1、在SQL Server中,我们使用 select top N * ......
文章导航 SQL Server 2005 学习笔记系列文章导航
这一节咱们来说说ClR的性能,我们不能只使用它而不去考虑到低 为什么要使用它或是在什么时候应该使用它,像我之前写的函数得到一个字符的长度的方法就没有太大必要了,但如果是像拆分字符这样的方法应该就有必要了,比如c#里的Split ......