1. Split the string by the specified symbol and return the number of elements after the split (the method is very simple, that is, to check the number of separators in the string, and then add one, which is the required result .) CREATEfunctionGet_StrArrayLength (10) -- separator) (rtrim (@ str) (@ split, @ str) (@ split, @ str ,@
1. Split the string by the specified symbol and return the number of elements after the split (the method is very simple, that is, to check the number of separators in the string, and then add one, which is the required result .) CREATE function Get_StrArrayLength (10) -- delimiter number) (rtrim (@ str) (@ split, @ str) (@ split, @ str ,@
1. Split the string by the specified symbol, the U.S. server, and website space. The number of elements after the split is returned. (The method is very simple. The Hong Kong server is to check the number of separators in the string, and then add one, that is, the result of the request .) CREATE function Get_StrArrayLength (10) -- delimiter number) (rtrim (@ str) (@ split, @ str) (@ split, @ str, @ start) [Call example:,) Return Value: 4] 2. Split the string by the specified symbol and return the elements of the specified index after the split. CREATE function Get_StrArrayStrOfIndex () is as convenient as an array (() returns varchar (1024) (rtrim (@ str) (@ split, @ str) (@ split, @ str, @ start) () end
[Call example:, 2) Return Value: 9] 3. combine the two functions above to traverse the element (50) dbo in the string like an array. get_StrArrayLength (), @ next) Call result: