


SQL Server基本函數(shù)詳細(xì)介紹
1、字符串函數(shù)
長度與分析用
datalength(Char_expr) 返回字符串包含字符數(shù),但不包含后面的空格
substring(expression,start,length) 不多說了,取子串
right(char_expr,int_expr) 返回字符串右邊int_expr個(gè)字符
字符操作類
upper(char_expr) 轉(zhuǎn)為大寫
lower(char_expr) 轉(zhuǎn)為小寫
space(int_expr) 生成int_expr個(gè)空格
replicate(char_expr,int_expr)復(fù)制字符串int_expr次
reverse(char_expr) 反轉(zhuǎn)字符串
stuff(char_expr1,start,length,char_expr2) 將字符串char_expr1中的從
start開始的length個(gè)字符用char_expr2代替
ltrim(char_expr) rtrim(char_expr) 取掉空格
ascii(char) char(ascii) 兩函數(shù)對(duì)應(yīng),取ascii碼,根據(jù)ascii嗎取字符
字符串查找
charindex(char_expr,expression) 返回char_expr的起始位置
patindex("%pattern%",expression) 返回指定模式的起始位置,否則為0
2.數(shù)學(xué)函數(shù)
abs(numeric_expr) 求絕對(duì)值
ceiling(numeric_expr) 取大于等于指定值的最小整數(shù)
exp(float_expr) 取指數(shù)
floor(numeric_expr) 小于等于指定值得最大整數(shù)
pi() 3.1415926.........
power(numeric_expr,power) 返回power次方
rand([int_expr]) 隨機(jī)數(shù)產(chǎn)生器
round(numeric_expr,int_expr) 安int_expr規(guī)定的精度四舍五入
sign(int_expr) 根據(jù)正數(shù),0,負(fù)數(shù),,返回+1,0,-1
sqrt(float_expr) 平方根
3.日期函數(shù)
getdate() 返回日期
datename(datepart,date_expr) 返回名稱如 June
datepart(datepart,date_expr) 取日期一部份
datediff(datepart,date_expr1.dateexpr2) 日期差
dateadd(datepart,number,date_expr) 返回日期加上 number
上述函數(shù)中datepart的
寫法 取值和意義
yy 1753-9999 年份
qq 1-4 刻
mm 1-12 月
dy 1-366 日
dd 1-31 日
wk 1-54 周
dw 1-7 周幾
hh 0-23 小時(shí)
mi 0-59 分鐘
ss 0-59 秒
ms 0-999 毫秒
日期轉(zhuǎn)換
convert()
4.系統(tǒng)函數(shù)
suser_name() 用戶登錄名
user_name() 用戶在數(shù)據(jù)庫中的名字
user 用戶在數(shù)據(jù)庫中的名字
show_role() 對(duì)當(dāng)前用戶起作用的規(guī)則
db_name() 數(shù)據(jù)庫名
object_name(obj_id) 數(shù)據(jù)庫對(duì)象名
col_name(obj_id,col_id) 列名
col_length(objname,colname) 列長度
valid_name(char_expr) 是否是有效標(biāo)識(shí)符
關(guān)鍵字:數(shù)據(jù)庫、SQL Server、函數(shù)
新文章:
- CentOS7下圖形配置網(wǎng)絡(luò)的方法
- CentOS 7如何添加刪除用戶
- 如何解決centos7雙系統(tǒng)后丟失windows啟動(dòng)項(xiàng)
- CentOS單網(wǎng)卡如何批量添加不同IP段
- CentOS下iconv命令的介紹
- Centos7 SSH密鑰登陸及密碼密鑰雙重驗(yàn)證詳解
- CentOS 7.1添加刪除用戶的方法
- CentOS查找/掃描局域網(wǎng)打印機(jī)IP講解
- CentOS7使用hostapd實(shí)現(xiàn)無AP模式的詳解
- su命令不能切換root的解決方法
- 解決VMware下CentOS7網(wǎng)絡(luò)重啟出錯(cuò)
- 解決Centos7雙系統(tǒng)后丟失windows啟動(dòng)項(xiàng)
- CentOS下如何避免文件覆蓋
- CentOS7和CentOS6系統(tǒng)有什么不同呢
- Centos 6.6默認(rèn)iptable規(guī)則詳解