sql基本函數(shù)大全
發(fā)布日期:2022-02-04 08:56 | 文章來源:源碼之家
1.字符串函數(shù)長(zhǎng)度與分析用
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的
寫法取值和意義
yy1753-9999年份
qq1-4刻
mm1-12月
dy1-366日 dd1-31日
wk1-54周
dw1-7周幾
hh0-23小時(shí)
mi0-59分鐘
ss0-59秒
ms0-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)列長(zhǎng)度
valid_name(char_expr)是否是有效標(biāo)識(shí)符
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
相關(guān)文章