说说你所熟知的MSSQL中的substring函数

*:first-child {
margin-top: 0 !important;
}

body>*:last-child {
margin-bottom: 0 !important;
}

/* BLOCKS
=============================================================================*/

p, blockquote, ul, ol, dl, table, pre {
margin: 15px 0;
}

/* HEADERS
=============================================================================*/

h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
}

h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
font-size: inherit;
}

h1 {
font-size: 28px;
color: #000;
}

h2 {
font-size: 24px;
border-bottom: 1px solid #ccc;
color: #000;
}

h3 {
font-size: 18px;
}

h4 {
font-size: 16px;
}

h5 {
font-size: 14px;
}

h6 {
color: #777;
font-size: 14px;
}

body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
margin-top: 0;
padding-top: 0;
}

a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0;
}

h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
margin-top: 10px;
}

/* LINKS
=============================================================================*/

a {
color: #4183C4;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

/* LISTS
=============================================================================*/

ul, ol {
padding-left: 30px;
}

ul li > :first-child,
ol li > :first-child,
ul li ul:first-of-type,
ol li ol:first-of-type,
ul li ol:first-of-type,
ol li ul:first-of-type {
margin-top: 0px;
}

ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0;
}

dl {
padding: 0;
}

dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px;
}

dl dt:first-child {
padding: 0;
}

dl dt>:first-child {
margin-top: 0px;
}

dl dt>:last-child {
margin-bottom: 0px;
}

dl dd {
margin: 0 0 15px;
padding: 0 15px;
}

dl dd>:first-child {
margin-top: 0px;
}

dl dd>:last-child {
margin-bottom: 0px;
}

/* CODE
=============================================================================*/

pre, code, tt {
font-size: 12px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
}

code, tt {
margin: 0 0px;
padding: 0px 0px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px;
}

pre>code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent;
}

pre {
background-color: #f8f8f8;
border: 1px solid #ccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px;
}

pre code, pre tt {
background-color: transparent;
border: none;
}

kbd {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #DDDDDD;
background-image: linear-gradient(#F1F1F1, #DDDDDD);
background-repeat: repeat-x;
border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
border-image: none;
border-radius: 2px 2px 2px 2px;
border-style: solid;
border-width: 1px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
line-height: 10px;
padding: 1px 4px;
}

/* QUOTES
=============================================================================*/

blockquote {
border-left: 4px solid #DDD;
padding: 0 15px;
color: #777;
}

blockquote>:first-child {
margin-top: 0px;
}

blockquote>:last-child {
margin-bottom: 0px;
}

/* HORIZONTAL RULES
=============================================================================*/

hr {
clear: both;
margin: 15px 0;
height: 0px;
overflow: hidden;
border: none;
background: transparent;
border-bottom: 4px solid #ddd;
padding: 0;
}

/* IMAGES
=============================================================================*/

img {
max-width: 100%
}
-->

说说你所熟知的MSSQL中的substring函数

函数签名:

substring
--expression (varchar,nvarchar,text,ntext,varbinary,or image)
--Starting position (bigint)
--Length (bigint) 从函数名称来看,是截取字符串内容。
从函数签名来看,不仅能截取字符串内容,还能截取二进制内容

那么,你觉得如下应该sql语句应该是什么结果呢?

select subString('123456',0,1)
select subString('123456',1,1)
select subString('123456',-1,2)
select subString('123456',-1,3)

如果想好了,但不确定,那赶紧打开工具执行看看吧

你答对了吗?为什么会是那些结果,能解释吗?

三大知识点:

1. MSSQL中,下标从1开始,注意:不是大多数编程语言采用的0。
2. substring函数的调用substring(str,startIndex,length)
效果上是转换为substring(str,startIndex,endIndex)来运算的,
endIndex=startIndex+length。
3. 对于区间取值,采取的是前闭后开的策略,也有是说包含开始下标,但是不包含结束下标。

那么能解释上面的代码了吗?

说说你所熟知的MSSQL中的substring函数的更多相关文章

  1. SQL中CHARINDEX()/INSTR()函数和SUBSTRING()/SUBSTR()函数

    一.SQLServer中的CHARINDEX() 和ORACLE中的INSTR()函数 1.INSTR(C1,C2[,I[,J]]) [功能]在一个字符串中搜索指定的字符,返回发现指定的字符的位置; ...

  2. SQL中SUBSTRING函数的用法

    功能:返回字符.二进制.文本或图像表达式的一部分 语法:SUBSTRING ( expression, start, length ) SQL 中的 substring 函数是用来抓出一个栏位资料中的 ...

  3. Java中substring函数的简单应用

    1.删掉一个字符串中的某个字符 /* * 使用Java 中的 substring()函数删掉字符串中的某个字符 * deleteAssignChar函数的参数说明: * str:被操作的字符串 * o ...

  4. C#和Java中的Substring()

    吐槽-使用清理软件整理电脑要注意,不要清理的"太狠",不然你会受伤的! C#中的Substring() 示例 实现代码 using System;using System.Coll ...

  5. Mssql中一些常用数据类型的说明和区别

    Mssql中一些常用数据类型的说明和区别 1.bigint 占用8个字节的存储空间,取值范围在-2^63 (-9,223,372,036,854,775,808) 到 2^63-1 (9,223,37 ...

  6. [转]JDK6和JDK7中的substring()方法

    substring(int beginIndex, int endIndex)在JDK6与JDK7中的实现方式不一样,理解他们的差异有助于更好的使用它们.为了简单起见,下面所说的substring() ...

  7. Java-J2SE学习笔记-查找一个String中,subString的出现次数

    1.查找一个String中,subString的出现次数 2.代码 package Test; public class TestStringContain { public static void ...

  8. mysql数据表如何导入MSSQL中

    本案例演示所用系统是windows server 2012.其它版本windows操作系统类似. 1,首先需要下载mysql odbc安装包. http://dev.mysql.com/downloa ...

  9. JDK6和JDK7中的substring()方法

    substring(int beginIndex, int endIndex)在JDK6与JDK7中的实现方式不一样,理解他们的差异有助于更好的使用它们.为了简单起见,下面所说的substring() ...

随机推荐

  1. Python中的*args和**kwarg

    可变参数 *args 允许你传入0个或任意个参数,这些可变参数在函数调用时自动组装为一个tuple, 而 关键字参数 **kw 允许你传入0个或任意个含参数名的参数,这些关键字参数在函数内部自动组装为 ...

  2. aehyok.com的成长之路二——技术选型

    前言   首先奉上个人网站地址传送门:aehyok.com 在上一篇博客中http://www.cnblogs.com/aehyok/p/3934197.html主要简单的介绍了自己做个人网站的初衷, ...

  3. FPGA4U FPGA SDRAM Controller

    -- https://fpga4u.epfl.ch/wiki/FPGA4U_Description -- The SDRAM bits data ..> signals, -- one ..&g ...

  4. 无线电源传输 Wireless Power Consortium (WPC) Communication

    Universally Compatible Wireless Power Using the Qi Protocol Wireless charging of portable electronic ...

  5. arcgis server10.1注册服务——避免在发布服务中拷贝数据

    之前用的arcgis10.1前的版本,后来换成10.1还有点不习惯,变化挺多的.发布服务过程中,进行分析的时候,其中有一项提醒:xxx图层没有注册到服务,很纳闷,为什么会有这种提示,不管,点击发布,会 ...

  6. WPF 的datagrid 列名中没有显示下划线是怎么回事?

    引用:http://www.cnblogs.com/sqzhuyi/archive/2011/07/26/sqlserverclient.html#2831497 功能介绍:输入查询语句,显示列表 出 ...

  7. arcgis flexviewer中由Application向widget传值

    arcgis flexviewer所有的小部件类均继承自com.esri.viewer.BaseWidget基类,而BaseWidget又继承了com.esri.viewer.IBaseWidget接 ...

  8. Mac OS 下安装wget

    环境:  Mac OS X 10.9.4 1 下载源码 地址: http://ftp.gnu.org/gnu/wget/wget-1.9.tar.gz 2 解压安装 tar zxvf wget-1.9 ...

  9. 读Java 804 - Quick refresher

    Upcast永远是成功的,但Downcast不是,记得做instanceof判断 仅抛不同异常,而返回值相同的重载是不可以的 static import只会import静态类 static metho ...

  10. Arduino 封装库

    这里是一个在Arduino平台下将常用的代码以库的形式封装的示例. 第一步:在Arduino的安装目录下的对应目录建立文件夹 C:\Program Files (x86)\Arduino\librar ...