Create Function split (<br/> @ stringtosplit varchar (2048), <br/> @ separator varchar (128 )) <br/> Returns table as return <br/> with indices as <br/> (<br/> select 0 s, 1 E <br/> Union all <br/> select e, charindex (@ separator, @ stringtosplit, e) + Len (@ separator) <br/> from indices <br/> where E> S <br/>) <br/> select substring (@ stringtosplit, S, <br/> case when E> Len (@ separator) then e-S-len (@ separator) else Len (@ stringtosplit)-S + 1 end) string <br/>, s startindex <br/> from indices where S> 0 <br/> then use the following method to obtain <br/> select string from Split ('22 | 23 | 34 ', '|') group by string
Result:
String
Zookeeper ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
22
23
34
(3 rows affected)