SQL SERVER INSTR
时间: 2024-03-13 13:25:51 浏览: 149
The INSTR function is not a valid function in SQL Server. However, SQL Server provides a similar function called CHARINDEX, which is used to find the starting position of a substring within a string.
The syntax for CHARINDEX is as follows:
CHARINDEX(substring, string, start_position)
- substring: the substring to search for
- string: the string to search within
- start_position: (optional) the position to start the search from. If not specified, the search starts at the beginning of the string.
The function returns the starting position of the first occurrence of the substring within the string, or 0 if the substring is not found.
Example:
SELECT CHARINDEX('world', 'Hello world') -- returns 7
In this example, the function returns 7 because the substring 'world' starts at the 7th position in the string 'Hello world'.
阅读全文