MSSQL中使用子字符串查找的实现(mssql子字符串查找)

Substring Location in MSSQL

创新互联建站专业为企业提供柳州网站建设、柳州做网站、柳州网站设计、柳州网站制作等企业网站建设、网页设计与制作、柳州企业网站模板建站服务,十载柳州做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

In Microsoft SQL Server, a substring is a portion of a character string, typically consisting of one or more characters. It may be used to select some or all characters in a string. You can get the start or location of a substring within a character string in Microsoft SQL Server using the charindex() function. The charindex() function searches a certain character string (called the search string) within another character string and returns the start location of the search string, or 0 if the search string characters cannot be found.

For example, you may have a character string “Microsoft SQL Server” and you want to find the starting position of the substring “SQL”. The following statement can be used:

SELECT CHARINDEX(‘SQL’, ‘Microsoft SQL Server’)

The above statement returns 10 because the keyword “SQL” is located at the 10th character in the character string.

The charindex() function also works with Unicode and extended ASCII characters.

The charindex() function provides several additional argument options for more advanced substring query/search. For example, the third argument of the charindex() function specifies the starting position in the character string from which the search begins. The following statement returns the location of the substring “SQL” starting from the 11th character:

SELECT CHARINDEX(‘SQL’, ‘Microsoft SQL Server’, 11)

The fourth argument allows the substring search case to be specified. It is set to false by default, which means that case is ignored. To perform a case-sensitive search, it should be set to true.

SELECT CHARINDEX(‘SQL’, ‘Microsoft SQL Server’, 0, true)

The charindex() function can be used with other string manipulation functions to perform various tasks such as extracting a substring of a larger string. It can also be used in combination with other data manipulation language (DML) statements such as SELECT, UPDATE, and DELETE to perform complex operations on string data.

In summary, the charindex() function allows a substring location to be quickly and easily retrieved in MSSQL. It provides both basic and advanced options for substring string manipulation.

香港服务器选创新互联,2H2G首月10元开通。
创新互联(www.cdcxhl.com)互联网服务提供商,拥有超过10年的服务器租用、服务器托管、云服务器、虚拟主机、网站系统开发经验。专业提供云主机、虚拟主机、域名注册、VPS主机、云服务器、香港云服务器、免备案服务器等。

网站题目:MSSQL中使用子字符串查找的实现(mssql子字符串查找)
分享URL:http://www.gawzjz.com/qtweb/news5/167555.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联