sql 随笔 2015-07-02
sql 自定义函数
--检查函数是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'dbo.pTitleCase') and xtype in (N'FN', N'IF', N'TF'))
drop function dbo.pTitleCase ;
go --创建函数
create function dbo.pTitleCase(@strIn nvarchar(Max))
returns nvarchar(Max)
as
begin;
declare
@strOut nvarchar(max),
@currentPostion int,
@nextSpace int,
@currentWord nvarchar(max),
@strLen int,
@lastWord bit; set @nextSpace = 1;
set @currentPostion =1;
set @strOut ='';
set @strLen=Len(@strIn);
set @lastWord=0; while @lastWord=0
begin;
set @nextSpace=CharIndex( ' ',@strIn,@currentPostion+1)
if @nextSpace=0 --no more spaces found
begin;
set @nextSpace=@strLen;
set @lastWord=1;
end; set @currentWord = Upper(substring(@strIn,@currentPostion,1));
set @currentWord = @currentWord + lower(substring(@strin,@currentPostion+1,@nextSpace-@currentPostion));
set @strOut=@strOut+@currentWord;
set @currentPostion=@nextSpace+1;
end;
return @strOut;
end;
go --执行函数
SELECT [Demo].[dbo].[pTitleCase] ( 'one TWO tHrEe')
go
sql 随笔 2015-07-02的更多相关文章
- Myeclipse 2015 stable 1.0 完美破解方法(转自 http://yangl.net/2015/07/14/myeclipse_2015stable_1/)
Myeclipse 2015 stable 1.0 完美破解方法 http://yangl.net/2015/07/14/myeclipse_2015stable_1/ 破解包(注册机)下载地址:链接 ...
- Murano Weekly Meeting 2015.07.21
会议时间: 2015.07.21 主持人: Kirill Zaitsev, core from Mirantis 会议摘要: 1.murano client和murano dashboard升级到y ...
- Murano Weekly Meeting 2015.07.14
会议时间: 2015.07.14 主持人: Kirill Zaitsev, core from Mirantis 会议摘要: 1.periodic nightly builds,然后通过mailin ...
- 2021.07.02 P1383 高级打字机题解(可持久化平衡树)
2021.07.02 P1383 高级打字机题解(可持久化平衡树) 分析: 从可以不断撤销并且查询不算撤销这一骚操作可以肯定这是要咱建一棵可持久化的树(我也只会建可持久化的树,当然,还有可持久化并查集 ...
- 2021.07.02 UVa1197 多路归并模板
2021.07.02 UVa1197 多路归并模板 UVA11997 K Smallest Sums - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 分析: 题解 UVA11997 ...
- SQL Tuning 基础概述02 - Explain plan的使用
1.explain plan的使用 SQL> explain plan for delete from t_jingyu; Explained. SQL> select * from ta ...
- Archlinux 2015.07.01 和 Windows7 双系统 安装教程
提前在windows7下给Archlinux预留一个分区,大小最好在20G以上(根据自己硬盘情况分配). 第一步,安装前的准备 从arch官网下载最新的ISO文件archlinux-2015.07.0 ...
- SQL Server编程(02)自定义函数
在编程过程中,我们通常把特定的功能语句块封装称函数,方便代码的重用.我们可以在SQL Server中自定义函数,根据函数返回值的区别,我们自定义的函数分两种:标量值函数和表值函数. 自定义函数的优点: ...
- spark SQL随笔
sparkSQL 1.主要的数据结构 DataFreames 2.开始使用:SQLContext 创建步骤: Val sc:sparkContext Val sqlContext=new org. ...
随机推荐
- beego 0.9.0 中智能路由AutoRouter的使用方法及源码解读
了解beego的开发者肯定知道,beego的路由设计来源于sinatra,原来是不支持自动路由的,每一个路由都要自己配置的,如: type MainController struct { beego. ...
- Python Socket File Transfer
I have a RPi which I intented to use it to crawl data. The development environment in RPi is very ba ...
- c++ switch case
http://www.cnblogs.com/RealOnlyme/articles/2579628.html
- python 安装 easy_intall 和 pip python无root权限安装
http://www.cnblogs.com/haython/p/3970426.html easy_install和pip都是用来下载安装Python一个公共资源库PyPI的相关资源包的 首先安装e ...
- Ext学习-基础概念,核心思想介绍
1.目标 本阶段的目标是通过学习一些基础知识来对EXTJS有个整体的了解,知道EXTJS的基础语法,核心设计思想等等 2.内容 1.基础部分学习 2.EXTJS类系统介绍 3.EXTJ ...
- Why am I able to change the contents of const char *ptr?
http://stackoverflow.com/questions/3228664/why-am-i-able-to-change-the-contents-of-const-char-ptr I ...
- vc6命令行编译工程方法
查vc++ 6.0 的 msdn找到下面的命令: msdev FileName [/MAKE "ProjectName – ConfigName | ALL"] [/REBUILD ...
- 给Jquery添加alert,prompt方法,类似系统的Alert,Prompt,可以响应键盘,支持拖动
我们在调用系统的Alert,prompt的弹出提示时,不同的系统会有不同的提示框,视觉效果不统一,而且不好看,功能单一,现在我们通过Jquery模拟Alert,prompt,现实统一视觉效果,而且内容 ...
- Unity3D脚本中文系列教程(十四)
http://dong2008hong.blog.163.com/blog/static/469688272014032134394/ WWWFrom 类Unity3D脚本中文系列教程(十三)辅助类. ...
- Tutorial: Model
What is a model? Across the internet the definition of MVC is so diluted that it's hard to tell what ...