ylb:SQLServer常用系统函数-字符串函数、配置函数、系统统计函数

ylbtech-SQL Server:SQL Server-SQLServer常用系统函数

-- =============================================
-- ylb:SQLServer常用系统函数-字符串函数、配置函数、系统统计函数
-- Comments:字符串函数,配置函数,SQL Server
-- KeyWord:SQL Server
-- author:yuanbo
-- ylb: ylb,tech
-- 13:41 2012/2/17
-- =============================================

ylb:SQLServer 常用系统函数-字符串函数、配置函数、系统统计函数 返回顶部
--=============================================================
-- ylb:以Northwind为例,讲述常用的MSSQL Server的一些函数
--=============================================================
use Northwind
go
--=============================================================
-- ylb:1,字符串函数
--=============================================================
select * from Products
---Char()
select CHAR(3) 
go
--LEN()
-- 字符串的长度
select LEN(ProductName) from Products
go
--Lower()
-- 字符串全部转为小写
select Lower(ProductName) from Products
go
--Upper()
-- 字符串全部转为大写
select Upper(ProductName) from Products
go
---Ltrim()
-- 取出字符串左边的空格
select Ltrim(ProductName) from Products
go
---Rtrim()
-- 取出字符串右边的空格
select Rtrim(ProductName) from Products
go
--Str()
-- 将其它类型转换为字符类型
select 'price:'+Str(UnitPrice) from Products
go
--Substring()
-- 截取字符串,给一个开始截取的位置索引,再给以要截取的长度
select SUBSTRING(ProductName,3,7) from Products
go
--=============================================================
-- ylb:2,配置函数
--=============================================================
--@@LANGUAGE
-- 当前所用的语言
select @@LANGUAGE
go
--@@LOCK_TIMEOUT
-- 当前会话当超时的设置(毫秒)
select @@LOCK_TIMEOUT
go
--@@VERSION
-- 当前安装的SQL Server安装日期,版本和处理器型
select @@VERSION
go
--@@SERVERNAME
-- 本地SQL Server的名称
select @@SERVERNAME
go
--@@SERVICENAME
-- 目前于运行SQL Server服务器的注册名称
select @@SERVICENAME
go
--@@NESTLEVEL
-- 当前存储过程执行嵌套的级别(初始值为:0)
select @@NESTLEVEL
go
--=============================================================
-- ylb:3,系统统计函数
--=============================================================
warn 作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
posted on 2014-01-07 11:36  ylbtech  阅读(631)  评论(0编辑  收藏  举报