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