ylbtech-SQL Server:SQL Server-SQLServer常用系統(tǒng)函數(shù) |
-- =============================================-- ylb:SQLServer常用系統(tǒng)函數(shù)-字符串函數(shù)、配置函數(shù)、系統(tǒng)統(tǒng)計(jì)函數(shù)-- Comments:字符串函數(shù),配置函數(shù),SQL Server-- KeyWord:SQL Server-- author:yuanbo-- ylb: ylb,tech-- 13:41 2012/2/17-- =============================================
ylb:SQLServer 常用系統(tǒng)函數(shù)-字符串函數(shù)、配置函數(shù)、系統(tǒng)統(tǒng)計(jì)函數(shù) 返回頂部 |
--=============================================================-- ylb:以Northwind為例,講述常用的MSSQL Server的一些函數(shù)--=============================================================use Northwindgo--=============================================================-- ylb:1,字符串函數(shù)--=============================================================select * from PRoducts---Char()select CHAR(3) go--LEN()-- 字符串的長(zhǎng)度select LEN(ProductName) from Productsgo--Lower()-- 字符串全部轉(zhuǎn)為小寫(xiě)select Lower(ProductName) from Productsgo--Upper()-- 字符串全部轉(zhuǎn)為大寫(xiě)select Upper(ProductName) from Productsgo---Ltrim()-- 取出字符串左邊的空格select Ltrim(ProductName) from Productsgo---Rtrim()-- 取出字符串右邊的空格select Rtrim(ProductName) from Productsgo--Str()-- 將其它類(lèi)型轉(zhuǎn)換為字符類(lèi)型select 'price:'+Str(UnitPrice) from Productsgo--Substring()-- 截取字符串,給一個(gè)開(kāi)始截取的位置索引,再給以要截取的長(zhǎng)度select SUBSTRING(ProductName,3,7) from Productsgo--=============================================================-- ylb:2,配置函數(shù)--=============================================================--@@LANGUAGE-- 當(dāng)前所用的語(yǔ)言select @@LANGUAGEgo--@@LOCK_TIMEOUT-- 當(dāng)前會(huì)話(huà)當(dāng)超時(shí)的設(shè)置(毫秒)select @@LOCK_TIMEOUTgo--@@VERSION-- 當(dāng)前安裝的SQL Server安裝日期,版本和處理器型select @@VERSIONgo--@@SERVERNAME-- 本地SQL Server的名稱(chēng)select @@SERVERNAMEgo--@@SERVICENAME-- 目前于運(yùn)行SQL Server服務(wù)器的注冊(cè)名稱(chēng)select @@SERVICENAMEgo--@@NESTLEVEL-- 當(dāng)前存儲(chǔ)過(guò)程執(zhí)行嵌套的級(jí)別(初始值為:0)select @@NESTLEVELgo--=============================================================-- ylb:3,系統(tǒng)統(tǒng)計(jì)函數(shù)--=============================================================
新聞熱點(diǎn)
疑難解答
圖片精選