Tell me about the substring function in the MSSQL that you are familiar with.

Source: Internet
Author: User

Tell me about the substring function in the MSSQL that you are familiar with.

Tell me about the substring function in the MSSQL that you are familiar with.

Function Signature:
substring    --expression (varchar,nvarchar,text,ntext,varbinary,or image)    --Starting position (bigint)    --Length (bigint)从函数名称来看,是截取字符串内容。从函数签名来看,不仅能截取字符串内容,还能截取二进制内容
So, what do you think should be the result of the SQL statement below?
If you think about it, but I'm not sure, just open the tool and take a look.
你答对了吗?为什么会是那些结果,能解释吗?
Three major points of knowledge:
1. MSSQL中,下标从1开始,注意:不是大多数编程语言采用的1。2. substring函数的调用substring(str,startIndex,length)   效果上是转换为substring(str,startIndex,endIndex)来运算的,   endIndex=startIndex+length。3. 对于区间取值,采取的是前闭后开的策略,也有是说包含开始下标,但是不包含结束下标。
So, can you explain the above code?

Tell me about the substring function in the MSSQL you are familiar with

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.