sqlserver 字符串split
时间:2021-07-01 10:21:17
帮助过:11人阅读
value
from TF_NJVALUES(
‘3C457A2D-188B-4D99-A822-2968054E1FB8,3C457A2D-188B-4D99-A822-2968054E1FB8‘)
CREATE FUNCTION TF_NJVALUES
(
@P0 varchar(
max)
--需要截取的字符
)
RETURNS @OUT_TABLE TABLE(value
VARCHAR(
max))
AS
BEGIN
DECLARE @SQL varchar(
max),
@output varchar(
50)
set @P0=case when RIGHT(
@P0,
1)
=‘,‘ then @P0 else @P0+‘,‘ end
while CHARINDEX(
‘,‘,
@P0)
>0
begin
set @output=LEFT(
@P0,
CHARINDEX(
‘,‘,
@P0)
-1)
INSERT INTO @OUT_TABLE(value)
SELECT RTRIM(
LTRIM(
@output))
set @P0=right(
@P0,
len(
@P0)
-CHARINDEX(
‘,‘,
@P0))
end
return
END
sqlserver 字符串split
标签:while returns into weight log style code pre ase