str_replace 將第1個字符串表達式中出現的第2個字符串表達式的所有實例替換為第3個表達式。
例如:select str_replace(‘aaabbbccc’,’bb’,’mm’) 結果:aaammbccc
compare 直接比較兩個字符串,如果不1樣,則返回⑴
right(char_expr,int_expr)
返回char_expr右側的int_expr字符
left(char_expr,int_expr)
返回char_expr左側的int_expr字符
Square(numeric)
例如:select square(price) from titles
Select square(5) 結果:25.0
注意:次函數同等于power(muneric_expr,2),但是它返回float類型而不返回int類型。
Select day(‘11/02/03’) 結果 2
month 返回1個整數,該整數表示月份。
例如:select month(getdate()) 結果:12
同理: select day(getdate()) 結果:15
select year(getdate()) 結果:2006
col_length 返回已定義的列的長度。如:返回表tablename 的title列的長度,selectcol_length(‘tablename’,’title’)
注意:對text和image,numeric列比較特殊。
col_name 返回已指定表 ID 和列 ID 的列的名稱,且最長可為 255 個字節。
語法 col_name(object_id, column_id [, database_id])
參數 object_id 是1個數值表達式,它是表、視圖或其它數據庫對象的對象 ID。它們 存儲在 sysobjects 的 id 列中
column_id是1個數值表達式,它表示1列的列 ID。它們存儲在 syscolumns 的colid 列中。
database_id是1個數值表達式,它表示數據庫的 ID。它們存儲在 sysdatabase 的db_id 列中。
curunreservedpas 返回指定磁盤區段中的可用頁數
Curunreservedpgs(dbid,istart,unreservedpgs)
dbid是數據庫的ID,它們存儲在sysdatabases的dbid字段。
Istart是要返回的頁所在磁盤區段中的1頁。
Unreservedpgs是在dbtable當前對所要求的數據庫不可用時返回的缺省值。
eg: 返回數據庫名稱、裝備名和每一個裝備區段中的未保存頁數。
select db_name(dbid),d.name,curunreservedpgs(dbid,1,unreservedpgs)
from sysusages u ,sysdevices d where d.low<=u.size+vstart
and d.high>=u.size+vstart - 1
and d.status &2 = 2
db_id 返回數據庫的ID號
Select db_id(‘pub’) 返回pub數據庫的id
Select db_id() 當前數據庫的ID
identity_burn_max 跟蹤給定表的identity burn最大值,此函數只返還只而不進行更新。
例如:select identity_burn_max(‘tablename’)
注意:返回的是自增列的最大ID,如果這個表沒有自增列,則返回為null
object_id 返回指定對象的對象ID,object_name是返回對象ID的對象名稱。
Obeject_di(object_name)
object_name是數據庫對象(表、視圖、進程、觸發器、缺省值或規則)的名稱。
例如:select object_id(‘TBL_ZONE’) 結果:437573566
一樣 selectobject_name(437573566) 結果:TBL_ZONE
注意:對象ID存儲在sysobjects的ID列中。
index_col 返回指定表或視圖中帶索引的列的名稱。
index_clolrder 返回列的順序
is_sec_service_on 安全服務啟用時返回1;否則返回0
is_sec_service_on(sevurity_service_nm)
其中:sevurity_service_nm是安全服務的名稱。
查找安全服務的有效名稱,用select * from syssecmechs
例如:select is_sec_service_on(“unifiedlogin”)
mut_excl_roles 返回有關兩個角色之間互斥性的信息。
mut_excl_roles是1個系統函數。如果系統安全員將role1定義為與role2互斥的角色,或直接有role2所包括的角色,則mut_excl_roles返回1,如果不是則返回0。
newid 根據提供的參數生成兩種不同格式的、人工可讀的全局唯1ID
Newid([optionflag])
例如:select newid()
select newid(0)
select newid(0x0)
select newid(1)
可以通過newid()來參數隨機器數
select id from tablename order by newid()
這時候你會發現,每次履行,排序都不1樣。
next_identity 檢查下1個insert可用的下1個標識值。(就是下1個自增的ID)
Next_identity(tablename)
例如:select next_identity(‘tbl_zone’) 結果:返回tbl_zone表中下1個要自增的id
注意:如果這個表不是自增,則返回null
proc_role 返回關因而否已授與用戶指定角色的信息。(通俗點就是你登陸后看看你是不是有某些角色,有則返回1,否則返回0)
例如:檢查用戶是不是已被授與系統安全員角色:
Select proc_role(‘sso_role’)
檢查用戶是不是已被授與系統安全員角色:
Select proc_role(‘oper_role’)
role_contain 當role2包括role1是返回1
role_contain(‘role1’,’role2’)
role_id 返回已指定名稱的角色的系統角色ID
role_name 返回已指定系統角色ID的角色名稱
role_id(‘role_name’)
role_ name’(role_id)
例如:返還sa_role的系統角色ID
Select role_id(‘sa_role’) 結果:0
Select role_name(0) 結果:sa_role
show_role 顯示登陸確當前啟用的角色。
例如:select show_role()
show_sec_services 列出可供會話使用的安全服務。
例如:select show_sec_services()
注意:如果沒有,則為null
suser_id 從syslogins表中返回服務器用戶的ID號
suser_name 從syslogins表中返回服務器用戶的名稱
Suser_id([server_user_name])
例如:select suser_id()
或 selectsuser_id(‘lei’)
select suser_name()
或 select suser_name(4)
syb_quit 終止連接.
例如:終止在其中履行該函數且返回毛病消息的連接.
Select syb_quit()
tempdb_id 報告給定會話分配到的臨時數據庫.
used_pgs 返回表或索引所用的頁數.
user 返回當前用戶的名稱.
user_id 返回數據庫中指定用戶或當前用戶的ID號
user_name 返回數據庫中指定用戶或當前用戶的名稱.
例如:select user_id()
或select user_id(‘lei’)
或select user_name()
或select user_name(4)
valid_name 如果指定字符串不是有效標識符,則返回0,否則返回非0數字
vaild_user 看是不是是1個數據庫中的有功效戶或別名.
上一篇 在電子,你會被加哪些技能點? ---電子學院專業課程分析
下一篇 測試